/**
 * 
 */
package com.disys.mb;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.OutputStream;
import java.io.Serializable;
import java.math.BigInteger;
import java.net.URLDecoder;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.primefaces.event.SelectEvent;

import com.disys.common.IProcessStatus;
import com.disys.common.IRecordType;
import com.disys.common.IReferenceType;
import com.disys.common.MetaData;
import com.disys.common.Util;
import com.disys.common.WriteToFile;
import com.disys.database.connectivity.DBConnectionManager;
import com.disys.facade.ProcessFacade;
import com.disys.facade.Rec000headerFacade;
import com.disys.facade.Rec140ERWOTCLOCFacade;
import com.disys.facade.Rec150erticswksiteFacade;
import com.disys.facade.Rec202emplpimFacade;
import com.disys.facade.Rec210emplpayinfoFacade;
import com.disys.facade.Rec220emplpaydtlFacade;
import com.disys.facade.Rec290empltaxcrdtFacade;
import com.disys.facade.Rec295Facade;
import com.disys.facade.Rec999footerFacade;
import com.disys.facade.RecReferenceValueFacade;
import com.disys.model.LdapUsers;
import com.disys.model.Process;
import com.disys.model.Rec000header;
import com.disys.model.Rec140ERWOTCLOC;
import com.disys.model.Rec150erticswksite;
import com.disys.model.Rec202emplpim;
import com.disys.model.Rec210emplpayinfo;
import com.disys.model.Rec220emplpaydtl;
import com.disys.model.Rec290empltaxcrdt;
import com.disys.model.Rec295EmpPayCheck;
import com.disys.model.Rec999footer;
import com.disys.model.RecReferenceValue;
import com.disys.procedures.ExecuteProcedures;

/**
 * @author Ubaid Raja
 * 
 */
@ViewScoped
@ManagedBean(name = "processMB")
public class ProcessMB extends AbstractMB implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4764928844708422053L;

	private static final transient Logger logger = Logger
			.getLogger(Rec140ERWOTCLOCMB.class.getName());

	private Process selectedProcess;
	public Process process;

	private List<Process> list;

	private ProcessFacade facade;

	private Rec150erticswksiteFacade rec150Facade;
	private Rec140ERWOTCLOCFacade rec140Facade;
	private Rec000headerFacade headerFacade;
	private Rec999footerFacade footerFacade;

	private Rec202emplpimFacade rec202Facade;
	private Rec210emplpayinfoFacade rec210Facade;
	private Rec220emplpaydtlFacade rec220Facade;
	private Rec290empltaxcrdtFacade rec290Facade;
	private Rec295Facade rec295Facade;

	private RecReferenceValueFacade objFacade;
	private Map<String, String> listOfSupportValues;

	private String reloadButtonVisible = "";
	private String finalizedButtonVisible = "";
	private String exportCurrentButtonVisible = "";
	private String ftpButtonVisible = "";
	private String reloadSpecific = "";

	private String selectedRecordId;
	private Integer selectedProcessId;

	private Map<String, String> recordTypeList;
	private Map<Integer, Integer> processList;

	public ProcessMB() {
		System.out.println("Process MB Called");
		reloadButtonVisible = "true";
		finalizedButtonVisible = "true";
		exportCurrentButtonVisible = "true";
		ftpButtonVisible = "true";
	}

	public void deleteProcess() {
		logger.info("Delete method called");
		System.out.println("Delete method called sys");
	}

	public String reloadSpecificData() {
		System.out.println("Reload specific data called sys");
		// TODO Follow following steps
		// 1 - Check if the last process was in the current week and is in
		// finalized state don't run this 'reload specific data'
		// check if this selected process is finalized.
		System.out.println("Selected Record is :" + selectedRecordId);
		System.out.println("Selected Process is :" + selectedProcessId);
		if (selectedRecordId.equals("-1")) {
			displayErrorMessageToUser("Select a record type first");
			return "";
		}

		if (selectedProcessId == -1) {
			displayErrorMessageToUser("Select a process first");
			return "";
		}

		Process pro = facade.findSingleProcess(selectedProcessId);
		if (pro.getStatus().equals(IProcessStatus.FINALIZED)) {
			displayErrorMessageToUser("This process is already finalized!!!");
			return "";
		}

		// TODO update process id in the table

		if (objFacade == null) {
			objFacade = getObjFacade();
		}
		List<RecReferenceValue> objRecReferenceValue = objFacade
				.findSupportingValues(IRecordType.REC_REF,
						IReferenceType.PROCESS_REFERENCE);

		String cName = "";
		String cValue = "";

		for (RecReferenceValue o : objRecReferenceValue) {
			cName = o.getColumnName();
			cValue = o.getColumnValue();

			if (cName.equals("process_id")) {
				cValue = pro.getId().toString();
			} else if (cName.equals("finalized")) {
				cValue = "0";
			}
			objFacade.updateReferences(IRecordType.REC_REF, cName, cValue,
					IReferenceType.PROCESS_REFERENCE);
		}

		// now call the procedure
		if (selectedRecordId.equals(IReferenceType.REC_140_REF)) {
			ExecuteProcedures.callStoreProcedure("sp_record140");
		} else if (selectedRecordId.equals(IReferenceType.REC_150_REF)) {
			ExecuteProcedures.callStoreProcedure("sp_record150");
		} else if (selectedRecordId.equals(IReferenceType.REC_202_REF)) {
			ExecuteProcedures.callStoreProcedure("sp_record202");
		} else if (selectedRecordId.equals(IReferenceType.REC_210_REF)) {
			ExecuteProcedures.callStoreProcedure("sp_record210");
		} else if (selectedRecordId.equals(IReferenceType.REC_220_REF)) {
			ExecuteProcedures.callStoreProcedure("sp_record220");
		} else if (selectedRecordId.equals(IReferenceType.REC_290_REF)) {
			ExecuteProcedures.callStoreProcedure("sp_record290");
		} else if (selectedRecordId.equals(IReferenceType.REC_295_REF)) {
			ExecuteProcedures.callStoreProcedure("sp_record295");
		}

		// displayInfoMessageToUser("Data already loaded once this week and is marked finalized, Can't load data now");

		return "";
	}

	private void callAllTheProcedures() {
		ExecuteProcedures.callStoreProcedure("sp_record140");
		ExecuteProcedures.callStoreProcedure("sp_record150");
		// ExecuteProcedures.callStoreProcedure("sp_record202");
		// ExecuteProcedures.callStoreProcedure("sp_record210");
		// ExecuteProcedures.callStoreProcedure("sp_record220");
		// ExecuteProcedures.callStoreProcedure("sp_record290");
		// ExecuteProcedures.callStoreProcedure("sp_record295");
	}

	public String reloadAllData() {
		logger.info("Reload all data called");
		System.out.println("Reload all data called sys");
		// TODO Follow following steps
		// 1 - Check if the last process was in the current week and is in
		// finalized state don't run this 'reload all data'
		Process object = facade.getLastFinalizedProcess("Process");
		if (object != null) {
			Integer week = object.getWeek();
			if (week == Util.getWeekNumber()) {
				displayErrorMessageToUser("Data already loaded once this week and is marked finalized, Can't load data now");
				return "";
			}
			// 2 - Create a new process object.
			Process objProcess = new Process();
			HttpServletRequest request = (HttpServletRequest) FacesContext
					.getCurrentInstance().getExternalContext().getRequest();
			Date date = new Date();
			long time = date.getTime();
			Timestamp ts = new Timestamp(time);
			HttpSession session = request.getSession();

			LdapUsers user = (LdapUsers) session.getAttribute("user");
			objProcess.setExecutedBy(user.getId());

			objProcess.setExecutionTime(ts);
			objProcess.setStatus(IProcessStatus.DRAFT);
			objProcess.setWeek(Util.getWeekNumber());
			objProcess.setWeekEndingDate(Util.getLastWeekDay());
			objProcess.setWeekStartingDate(Util.getFirstWeekDay());
			// 2 - Get new process id and save it in record reference table
			Integer processId = facade.insertProcessRecord(objProcess);

			// set column_name 'finalized' to 0 and column_name 'process_id' to
			// this
			// new process id against the
			// values of record type process_info.
			List<RecReferenceValue> objRecReferenceValue = getObjFacade()
					.findSupportingValues(IRecordType.REC_REF,
							IReferenceType.PROCESS_REFERENCE);

			String cName = "";
			String cValue = "";

			for (RecReferenceValue o : objRecReferenceValue) {
				cName = o.getColumnName();
				cValue = o.getColumnValue();

				if (cName.equals("process_id")) {
					cValue = processId.toString();
				} else if (cName.equals("finalized")) {
					cValue = "0";
				}
				objFacade.updateReferences(IRecordType.REC_REF, cName, cValue,
						IReferenceType.PROCESS_REFERENCE);
			}

			// 3 - Call the store procedure for every record.
			callAllTheProcedures();
			return "";
		} else {
			// 2 - Create a new process object.
			Process objProcess = new Process();
			HttpServletRequest request = (HttpServletRequest) FacesContext
					.getCurrentInstance().getExternalContext().getRequest();
			Date date = new Date();
			long time = date.getTime();
			Timestamp ts = new Timestamp(time);
			HttpSession session = request.getSession();

			LdapUsers user = (LdapUsers) session.getAttribute("user");
			objProcess.setExecutedBy(user.getId());

			objProcess.setExecutionTime(ts);
			objProcess.setStatus(IProcessStatus.DRAFT);
			objProcess.setWeek(Util.getWeekNumber());
			objProcess.setWeekEndingDate(Util.getLastWeekDay());

			// 2 - Get new process id and save it in record reference table
			Integer processId = facade.insertProcessRecord(objProcess);

			// set column_name 'finalized' to 0 and column_name 'process_id' to
			// this
			// new process id against the
			// values of record type process_info.
			List<RecReferenceValue> objRecReferenceValue = getObjFacade()
					.findSupportingValues(IRecordType.REC_REF,
							IReferenceType.PROCESS_REFERENCE);

			String cName = "";
			String cValue = "";

			for (RecReferenceValue o : objRecReferenceValue) {
				cName = o.getColumnName();
				cValue = o.getColumnValue();

				if (cName.equals("process_id")) {
					cValue = processId.toString();
				} else if (cName.equals("finalized")) {
					cValue = "0";
				}
				objFacade.updateReferences(IRecordType.REC_REF, cName, cValue,
						IReferenceType.PROCESS_REFERENCE);
			}
			callAllTheProcedures();
			return "";
		}
	}

	public String finalizedCurrentProcess() {

		System.out.println("finalizedCurrentProcess called sys");
		if (process != null) {
			// Process object = process;
			try {
				// TODO If another process in this week is finalized, show the
				// error message.
				// send the selected process's week and query if there is any
				// other process finalized in this week.
				List<Integer> list = getFacade().getFinalizeProcessOfAWeek(
						IRecordType.PROCESS, process.getWeek());
				if (list != null) {
					if (list.size() > 0) {
						displayErrorMessageToUser("Another process in this week is finalized, you can't finalize it.");
						finalizedButtonVisible = "false";
						return "";
					}
				}

				// Fetch this process object and update it.
				process.setStatus(IProcessStatus.FINALIZED);
				getFacade().updateProcess(process);

				// set column_name 'finalized' to 1 to this new process id
				// against the
				// values of record type process_info.
				if (objFacade == null) {
					objFacade = getObjFacade();
				}
				List<RecReferenceValue> objRecReferenceValue = objFacade
						.findSupportingValues(IRecordType.REC_REF,
								IReferenceType.PROCESS_REFERENCE);
				// qry =
				// "update referenc_table set column_value = 1  where column_name = 'finalized' and record_type = "+IReferenceType.PROCESS_REFERENCE;
				// qry =
				// "update referenc_table set column_value = "+process.getId().toString()+"  where column_name = 'process_id' and record_type = "+IReferenceType.PROCESS_REFERENCE;

				String cName = "";
				String cValue = "";

				for (RecReferenceValue o : objRecReferenceValue) {
					cName = o.getColumnName();
					cValue = o.getColumnValue();

					if (cName.equals("process_id")) {
						cValue = process.getId().toString();
					} else if (cName.equals("finalized")) {
						cValue = "1";
					}
					objFacade.updateReferences(IRecordType.REC_REF, cName,
							cValue, IReferenceType.PROCESS_REFERENCE);
				}
				// displayInfoMessageToUser("Records finalized successfully!!!");

				// run queries against every record to mark the values of this
				// process
				// id as finalized.
				// This method will finalize all the records.
				finalizeRecords(process.getId());

				process = null;
				finalizedButtonVisible = "true";
				return "";
			} catch (Exception e) {
				e.printStackTrace();
				return "";
			}
			// get all the processes and update them, set finalized to true
			// update every record i.e. set finalized = true where process_id =
			// selectedProcess.getId();
		}
		return "";
	}

	private void finalizeRecords(Integer processId) {

		BigInteger proId = BigInteger.valueOf(processId);
		getFacade().finalizeRecords(IRecordType.REC140, 1, proId);
		getFacade().finalizeRecords(IRecordType.REC150, 1, proId);
		getFacade().finalizeRecords(IRecordType.REC202, 1, proId);
		getFacade().finalizeRecords(IRecordType.REC210, 1, proId);
		getFacade().finalizeRecords(IRecordType.REC220, 1, proId);
		getFacade().finalizeRecords(IRecordType.REC290, 1, proId);
		getFacade().finalizeRecords(IRecordType.REC295, 1, proId);
	}

	/**
	 * @return the listOfSupportValues
	 */
	public Map<String, String> getListOfSupportValues(String recType) {
		List<RecReferenceValue> list = new ArrayList<RecReferenceValue>();
		list = getObjFacade()
				.findSupportingValues("RecReferenceValue", recType);
		if (listOfSupportValues == null) {
			listOfSupportValues = new HashMap<String, String>();
		}
		if (listOfSupportValues != null && listOfSupportValues.size() > 0) {
			listOfSupportValues.clear();
		}
		String key = "";
		String value = "";
		for (RecReferenceValue obj : list) {
			key = obj.getColumnName();
			value = obj.getColumnValue();
			listOfSupportValues.put(key, value);
		}
		return listOfSupportValues;
	}

	private void writeHeaderToFile(String recType, StringBuilder contents,
			File file, WriteToFile objWriteToFile) {
		// get data of header from reference table
		// create a header object
		Connection con = null;
		try {
			Rec000header object;
			object = getHeaderFacade().findSingleRecord();
			// find single record from the table, if it exists then its okay,
			// otherwise create a new record and save it in data base.
			if (object == null) {
				object = new Rec000header();
				listOfSupportValues = getListOfSupportValues(recType);
				object.setCode(listOfSupportValues.get("code"));
				object.setId1(listOfSupportValues.get("id_)1"));
				object.setRectype(listOfSupportValues.get("rectype"));
				object.setType(listOfSupportValues.get("type"));
				object.setVersion(listOfSupportValues.get("version"));
				headerFacade.createHeader(object);
				object = headerFacade.findSingleRecord();
			}
			Integer length = 0;
			// write header to the top of the file
			contents = new StringBuilder();
			con = DBConnectionManager
					.getConnection(DBConnectionManager.SQLSERVER);
			// con =
			// DBConnectionManager.getConnection(DBConnectionManager.MYSQL);

			HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
					"tx_000header");

			length = sizeOfColumns.get("rectype");
			if (object.getRectype() != null) {
				String rectype = object.getRectype();
				if (rectype.length() < length) {
					rectype = MetaData.appendSpaces(rectype, length);
				}
				contents.append(rectype);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}
			// add 91 spaces of filler here
			contents.append(MetaData.appendSpaces("", 91));

			contents.append(object.getVersion());

			contents.append(object.getId());

			length = sizeOfColumns.get("type");
			if (object.getType() != null) {
				String type = object.getType();
				if (type.length() < length) {
					type = MetaData.appendSpaces(type, length);
				}
				contents.append(type);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			contents.append(object.getCode());

			// add 5 spaces of source_service here
			contents.append(MetaData.appendSpaces("", 5));

			// add 1 space of empl_id_only here
			contents.append(MetaData.appendSpaces("", 1));

			contents.append(System.getProperty("line.separator"));

			objWriteToFile.writeToFile(file, contents.toString());
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (con != null) {
				try {
					con.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

	private void writeRec140ToFile(Connection con, StringBuilder contents,
			File file, WriteToFile objWriteToFile, BigInteger pId) {
		try {

			HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
					"tx_140ERWOTCLOC");

			List<Rec140ERWOTCLOC> objRec140erwotclocs = getRec140Facade()
					.findFinalizeRecords("Rec140ERWOTCLOC", 1, pId);

			System.out.println("Size of the list is : "
					+ objRec140erwotclocs.size());
			Integer length = 0;

			for (Rec140ERWOTCLOC ob : objRec140erwotclocs) {
				contents = new StringBuilder();
				// Rec140ERWOTCLOC record = manager.load(Rec140ERWOTCLOC.class,
				// ob);
				// System.out.println(ob.getCocode());
				// System.out.println(ob.getId());

				// System.out.println("Exported: " + manager.export(record));

				length = sizeOfColumns.get("rectype");
				if (ob.getRectype() != null) {
					String rectype = ob.getRectype();
					if (rectype.length() < length) {
						rectype = MetaData.appendSpaces(rectype, length);
					}
					contents.append(rectype);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("cocode");
				if (ob.getCocode() != null) {
					String cocode = ob.getCocode();
					if (cocode.length() < length) {
						cocode = MetaData.trailingSpaces(cocode, length);
					}
					contents.append(cocode);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				// add 75 spaces of filler here
				contents.append(MetaData.appendSpaces("", 75));

				contents.append(ob.getTci_id());

				length = sizeOfColumns.get("wotclocnumber");
				if (ob.getWotclocnumber() != null) {
					String wotclocnumber = ob.getWotclocnumber();
					if (wotclocnumber.length() < length) {
						wotclocnumber = MetaData.appendSpaces(wotclocnumber,
								length);
					}
					contents.append(wotclocnumber);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotclocname");
				if (ob.getWotclocname() != null) {
					String wotclocname = ob.getWotclocname();
					if (wotclocname.length() < length) {
						wotclocname = MetaData
								.appendSpaces(wotclocname, length);
					}
					contents.append(wotclocname);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotclocaddr_1");
				if (ob.getWotclocaddr_1() != null) {
					String wotclocaddr_1 = ob.getWotclocaddr_1();
					if (wotclocaddr_1.length() < length) {
						wotclocaddr_1 = MetaData.appendSpaces(wotclocaddr_1,
								length);
					}
					contents.append(wotclocaddr_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotclocaddr_2");
				if (ob.getWotclocaddr_2() != null) {
					String wotclocaddr_2 = ob.getWotclocaddr_2();
					if (wotclocaddr_2.length() < length) {
						wotclocaddr_2 = MetaData.appendSpaces(wotclocaddr_2,
								length);
					}
					contents.append(wotclocaddr_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotcloccity_1");
				if (ob.getWotcloccity_1() != null) {
					String wotcloccity_1 = ob.getWotcloccity_1();
					if (wotcloccity_1.length() < length) {
						wotcloccity_1 = MetaData.appendSpaces(wotcloccity_1,
								length);
					}
					contents.append(wotcloccity_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotclocstate_1");
				if (ob.getWotclocstate_1() != null) {
					String wotclocstate_1 = ob.getWotclocstate_1();
					if (wotclocstate_1.length() < length) {
						wotclocstate_1 = MetaData.appendSpaces(wotclocstate_1,
								length);
					}
					contents.append(wotclocstate_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotcloczip_1");
				if (ob.getWotcloczip_1() != null) {
					String wotcloczip_1 = ob.getWotcloczip_1();
					if (wotcloczip_1.length() < length) {
						wotcloczip_1 = MetaData.appendSpaces(wotcloczip_1,
								length);
					}
					contents.append(wotcloczip_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotcloccountry_1");
				if (ob.getWotcloccountry_1() != null) {
					String wotcloccountry_1 = ob.getWotcloccountry_1();
					if (wotcloccountry_1.length() < length) {
						wotcloccountry_1 = MetaData.appendSpaces(
								wotcloccountry_1, length);
					}
					contents.append(wotcloccountry_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				String wotclocfein = ob.getWotclocfein();
				length = sizeOfColumns.get("wotclocfein");
				if (wotclocfein.length() < length) {
					wotclocfein = MetaData.appendSpaces(wotclocfein, length);
				}
				contents.append(wotclocfein);

				contents.append(ob.getWotclocstscd());

				// add 10 spaces here for wotclocphnumber
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_1
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_2
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_3
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_4
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_5
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_6
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_7
				contents.append(MetaData.appendSpaces("", 10));

				// add 10 spaces here for wotclocrptlvl_8
				contents.append(MetaData.appendSpaces("", 10));

				contents.append(ob.getWotcfacilitybegindt());

				length = sizeOfColumns.get("wotcfacilityceasedt");
				if (ob.getWotcfacilityceasedt() != null) {
					String wotcfacilityceasedt = ob.getWotcfacilityceasedt();
					if (wotcfacilityceasedt.length() < length) {
						wotcfacilityceasedt = MetaData.appendSpaces(
								wotcfacilityceasedt, length);
					}
					contents.append(wotcfacilityceasedt);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				contents.append(System.getProperty("line.separator"));
				System.out.println(contents.toString());
				objWriteToFile.writeToFile(file, contents.toString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void writeRec150ToFile(Connection con, StringBuilder contents,
			File file, WriteToFile objWriteToFile, BigInteger pId) {
		try {
			HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
					"tx_150erticswksite");

			List<Rec150erticswksite> objRec150erticswksite = getRec150Facade()
					.findFinalizeRecords("Rec150erticswksite", 1, pId);

			System.out.println("Size of the list is : "
					+ objRec150erticswksite.size());
			Integer length = 0;

			for (Rec150erticswksite ob : objRec150erticswksite) {
				contents = new StringBuilder();
				// Rec140ERWOTCLOC record = manager.load(Rec140ERWOTCLOC.class,
				// ob);
				// System.out.println(ob.getCocode());
				// System.out.println(ob.getId());

				// System.out.println("Exported: " + manager.export(record));

				length = sizeOfColumns.get("rectype");
				if (ob.getRectype() != null) {
					String rectype = ob.getRectype();
					if (rectype.length() < length) {
						rectype = MetaData.appendSpaces(rectype, length);
					}
					contents.append(rectype);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("cocode");
				if (ob.getCocode() != null) {
					String cocode = ob.getCocode();
					if (cocode.length() < length) {
						cocode = MetaData.trailingSpaces(cocode, length);
					}
					contents.append(cocode);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				// add 75 spaces of filler here
				contents.append(MetaData.appendSpaces("", 75));

				contents.append(ob.getTciId());

				length = sizeOfColumns.get("ticsworksitelocnumber");
				if (ob.getTicsworksitelocnumber() != null) {
					String ticsworksitelocnumber = ob
							.getTicsworksitelocnumber();
					if (ticsworksitelocnumber.length() < length) {
						ticsworksitelocnumber = MetaData.appendSpaces(
								ticsworksitelocnumber, length);
					}
					contents.append(ticsworksitelocnumber);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticsworksitelocname");
				if (ob.getTicsworksitelocname() != null) {
					String ticsworksitelocname = ob.getTicsworksitelocname();
					if (ticsworksitelocname.length() < length) {
						ticsworksitelocname = MetaData.appendSpaces(
								ticsworksitelocname, length);
					}
					contents.append(ticsworksitelocname);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticsworksitelocaddr_1");
				if (ob.getTicsworksitelocaddr1() != null) {
					String ticsworksitelocaddr_1 = ob.getTicsworksitelocaddr1();
					if (ticsworksitelocaddr_1.length() < length) {
						ticsworksitelocaddr_1 = MetaData.appendSpaces(
								ticsworksitelocaddr_1, length);
					}
					contents.append(ticsworksitelocaddr_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticsworksitelocaddr_2");
				if (ob.getTicsworksitelocaddr2() != null) {
					String ticsworksitelocaddr_2 = ob.getTicsworksitelocaddr2();
					if (ticsworksitelocaddr_2.length() < length) {
						ticsworksitelocaddr_2 = MetaData.appendSpaces(
								ticsworksitelocaddr_2, length);
					}
					contents.append(ticsworksitelocaddr_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticsworksiteloccity_1");
				if (ob.getTicsworksiteloccity1() != null) {
					String ticsworksiteloccity_1 = ob.getTicsworksiteloccity1();
					if (ticsworksiteloccity_1.length() < length) {
						ticsworksiteloccity_1 = MetaData.appendSpaces(
								ticsworksiteloccity_1, length);
					}
					contents.append(ticsworksiteloccity_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticsworksitelocstate_1");
				if (ob.getTicsworksitelocstate1() != null) {
					String ticsworksitelocstate_1 = ob
							.getTicsworksitelocstate1();
					if (ticsworksitelocstate_1.length() < length) {
						ticsworksitelocstate_1 = MetaData.appendSpaces(
								ticsworksitelocstate_1, length);
					}
					contents.append(ticsworksitelocstate_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticsworksiteloczip_1");
				if (ob.getTicsworksiteloczip1() != null) {
					String ticsworksiteloczip_1 = ob.getTicsworksiteloczip1();
					if (ticsworksiteloczip_1.length() < length) {
						ticsworksiteloczip_1 = MetaData.appendSpaces(
								ticsworksiteloczip_1, length);
					}
					contents.append(ticsworksiteloczip_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticsworksiteloccountry_1");
				if (ob.getTicsworksiteloccountry1() != null) {
					String ticsworksiteloccountry_1 = ob
							.getTicsworksiteloccountry1();
					if (ticsworksiteloccountry_1.length() < length) {
						ticsworksiteloccountry_1 = MetaData.appendSpaces(
								ticsworksiteloccountry_1, length);
					}
					contents.append(ticsworksiteloccountry_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				// add 132 spaces of filler here
				contents.append(MetaData.appendSpaces("", 132));

				// add 25 spaces of ticsworksitephyscnty here
				contents.append(MetaData.appendSpaces("", 25));

				contents.append(System.getProperty("line.separator"));
				objWriteToFile.writeToFile(file, contents.toString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void writeRec202ToFile(Connection con, StringBuilder contents,
			File file, WriteToFile objWriteToFile, BigInteger pId) {

		HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
				"tx_202emplpim");

		List<Rec202emplpim> objRec202emplpims = getRec202Facade()
				.findFinalizeRecords("Rec202emplpim", 1, pId);

		System.out.println("Size of the list is : " + objRec202emplpims.size());
		Integer length = 0;
		Integer totalLength = 0;
		try {
			for (Rec202emplpim ob : objRec202emplpims) {
				contents = new StringBuilder();
				// Rec140ERWOTCLOC record = manager.load(Rec140ERWOTCLOC.class,
				// ob);
				// System.out.println(ob.getCocode());
				// System.out.println(ob.getId());

				// System.out.println("Exported: " + manager.export(record));

				length = sizeOfColumns.get("rectype");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getRectype() != null) {
					String rectype = ob.getRectype();
					if (rectype.length() < length) {
						rectype = MetaData.appendSpaces(rectype, length);
					}
					contents.append(rectype);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("cocode");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCocode() != null) {
					String cocode = ob.getCocode();
					if (cocode.length() < length) {
						cocode = MetaData.trailingSpaces(cocode, length);
					}
					contents.append(cocode);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ssn");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getSsn() != null) {
					String ssn = ob.getSsn();
					if (ssn.length() < length) {
						ssn = MetaData.trailingSpaces(ssn, length);
					}
					contents.append(ssn);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("empl_id");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmplId() != null) {
					String empl_id = ob.getEmplId();
					if (empl_id.length() < length) {
						empl_id = MetaData.trailingSpaces(empl_id, length);
					}
					contents.append(empl_id);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("user_id");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getUserId() != null) {
					String user_id = ob.getUserId();
					if (user_id.length() < length) {
						user_id = MetaData.trailingSpaces(user_id, length);
					}
					contents.append(user_id);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("inhousenum");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getInhousenum() != null) {
					String inhousenum = ob.getInhousenum();
					if (inhousenum.length() < length) {
						inhousenum = MetaData
								.trailingSpaces(inhousenum, length);
					}
					contents.append(inhousenum);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("pasofdate");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPasofdate() != null) {
					String pasofdate = ob.getPasofdate();
					if (pasofdate.length() < length) {
						pasofdate = MetaData.trailingSpaces(pasofdate, length);
					}
					contents.append(pasofdate);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("fn");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getFn() != null) {
					String fn = ob.getFn();
					if (fn.length() < length) {
						fn = MetaData.trailingSpaces(fn, length);
					}
					contents.append(fn);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("mn");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getMn() != null) {
					String mn = ob.getFn();
					if (mn.length() < length) {
						mn = MetaData.trailingSpaces(mn, length);
					}
					contents.append(mn);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ln");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getLn() != null) {
					String ln = ob.getLn();
					if (ln.length() < length) {
						ln = MetaData.trailingSpaces(ln, length);
					}
					contents.append(ln);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("suffix");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getSuffix() != null) {
					String suffix = ob.getFn();
					if (suffix.length() < length) {
						suffix = MetaData.trailingSpaces(suffix, length);
					}
					contents.append(suffix);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("title");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getTitle() != null) {
					String title = ob.getTitle();
					if (title.length() < length) {
						title = MetaData.trailingSpaces(title, length);
					}
					contents.append(title);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("dfpin");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getDfpin() != null) {
					String dfpin = ob.getDfpin();
					if (dfpin.length() < length) {
						dfpin = MetaData.trailingSpaces(dfpin, length);
					}
					contents.append(dfpin);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("direct_login");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getDirectLogin() != null) {
					String direct_login = ob.getDirectLogin();
					if (direct_login.length() < length) {
						direct_login = MetaData.trailingSpaces(direct_login,
								length);
					}
					contents.append(direct_login);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("verdiv");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getVerdiv() != null) {
					String verdiv = ob.getVerdiv();
					if (verdiv.length() < length) {
						verdiv = MetaData.trailingSpaces(verdiv, length);
					}
					contents.append(verdiv);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("jobtitle");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getJobtitle() != null) {
					String jobtitle = ob.getJobtitle();
					if (jobtitle.length() < length) {
						jobtitle = MetaData.trailingSpaces(jobtitle, length);
					}
					contents.append(jobtitle);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("eestatcd");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEestatcd() != null) {
					String eestatcd = ob.getEestatcd();
					if (eestatcd.length() < length) {
						eestatcd = MetaData.trailingSpaces(eestatcd, length);
					}
					contents.append(eestatcd);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("mrhdate");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getMrhdate() != null) {
					String mrhdate = ob.getMrhdate();
					if (mrhdate.length() < length) {
						mrhdate = MetaData.trailingSpaces(mrhdate, length);
					}
					contents.append(mrhdate);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("eestattype");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEestattype() != null) {
					String eestattype = ob.getEestattype();
					if (eestattype.length() < length) {
						eestattype = MetaData
								.trailingSpaces(eestattype, length);
					}
					contents.append(eestattype);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("orighiredate");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getOrighiredate() != null) {
					String orighiredate = ob.getOrighiredate();
					if (orighiredate.length() < length) {
						orighiredate = MetaData.trailingSpaces(orighiredate,
								length);
					}
					contents.append(orighiredate);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("termdate");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getTermdate() != null) {
					String termdate = ob.getTermdate();
					if (termdate.length() < length) {
						termdate = MetaData.trailingSpaces(termdate, length);
					}
					contents.append(termdate);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("termreason");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getTermreason() != null) {
					String termreason = ob.getTermreason();
					if (termreason.length() < length) {
						termreason = MetaData
								.trailingSpaces(termreason, length);
					}
					contents.append(termreason);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("uctermreason");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getUctermreason() != null) {
					String uctermreason = ob.getUctermreason();
					if (uctermreason.length() < length) {
						uctermreason = MetaData.trailingSpaces(uctermreason,
								length);
					}
					contents.append(uctermreason);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("lastdaywrkf");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getLastdaywrkf() != null) {
					String lastdaywrkf = ob.getLastdaywrkf();
					if (lastdaywrkf.length() < length) {
						lastdaywrkf = MetaData.trailingSpaces(lastdaywrkf,
								length);
					}
					contents.append(lastdaywrkf);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wrkstate");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getWrkstate() != null) {
					String wrkstate = ob.getWrkstate();
					if (wrkstate.length() < length) {
						wrkstate = MetaData.trailingSpaces(wrkstate, length);
					}
					contents.append(wrkstate);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wrkloccd");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getWrkloccd() != null) {
					String wrkloccd = ob.getWrkloccd();
					if (wrkloccd.length() < length) {
						wrkloccd = MetaData.trailingSpaces(wrkloccd, length);
					}
					contents.append(wrkloccd);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("fein");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getFein() != null) {
					String fein = ob.getFein();
					if (fein.length() < length) {
						fein = MetaData.trailingSpaces(fein, length);
					}
					contents.append(fein);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("suiacctnum");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getSuiacctnum() != null) {
					String suiacctnum = ob.getSuiacctnum();
					if (suiacctnum.length() < length) {
						suiacctnum = MetaData
								.trailingSpaces(suiacctnum, length);
					}
					contents.append(suiacctnum);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("adjhiredate");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getAdjhiredate() != null) {
					String adjhiredate = ob.getAdjhiredate();
					if (adjhiredate.length() < length) {
						adjhiredate = MetaData.trailingSpaces(adjhiredate,
								length);
					}
					contents.append(adjhiredate);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("yrsofserv");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getYrsofserv() != null) {
					String yrsofserv = ob.getYrsofserv();
					if (yrsofserv.length() < length) {
						yrsofserv = MetaData.trailingSpaces(yrsofserv, length);
					}
					contents.append(yrsofserv);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("mthofserv");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getMthofserv() != null) {
					String mthofserv = ob.getMthofserv();
					if (mthofserv.length() < length) {
						mthofserv = MetaData.trailingSpaces(mthofserv, length);
					}
					contents.append(mthofserv);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("payfreq");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPayfreq() != null) {
					String payfreq = ob.getPayfreq();
					if (payfreq.length() < length) {
						payfreq = MetaData.trailingSpaces(payfreq, length);
					}
					contents.append(payfreq);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("twn_add");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getTwnAdd() != null) {
					String twn_add = ob.getTwnAdd();
					if (twn_add.length() < length) {
						twn_add = MetaData.trailingSpaces(twn_add, length);
					}
					contents.append(twn_add);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ucx_add");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getUcxAdd() != null) {
					String ucx_add = ob.getUcxAdd();
					if (ucx_add.length() < length) {
						ucx_add = MetaData.trailingSpaces(ucx_add, length);
					}
					contents.append(ucx_add);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("add_ind_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getAddInd1() != null) {
					String add_ind_1 = ob.getAddInd1();
					if (add_ind_1.length() < length) {
						add_ind_1 = MetaData.trailingSpaces(add_ind_1, length);
					}
					contents.append(add_ind_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("type_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getType1() != null) {
					String type_1 = ob.getType1();
					if (type_1.length() < length) {
						type_1 = MetaData.trailingSpaces(type_1, length);
					}
					contents.append(type_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l1_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL11() != null) {
					String l1_1 = ob.getL11();
					if (l1_1.length() < length) {
						l1_1 = MetaData.trailingSpaces(l1_1, length);
					}
					contents.append(l1_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l2_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL12() != null) {
					String l2_1 = ob.getL12();
					if (l2_1.length() < length) {
						l2_1 = MetaData.trailingSpaces(l2_1, length);
					}
					contents.append(l2_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l3_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL13() != null) {
					String l3_1 = ob.getL13();
					if (l3_1.length() < length) {
						l3_1 = MetaData.trailingSpaces(l3_1, length);
					}
					contents.append(l3_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("city_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCity1() != null) {
					String city_1 = ob.getCity1();
					if (city_1.length() < length) {
						city_1 = MetaData.trailingSpaces(city_1, length);
					}
					contents.append(city_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("state_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getState1() != null) {
					String state_1 = ob.getState1();
					if (state_1.length() < length) {
						state_1 = MetaData.trailingSpaces(state_1, length);
					}
					contents.append(state_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("zip_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getZip1() != null) {
					String zip_1 = ob.getZip1();
					if (zip_1.length() < length) {
						zip_1 = MetaData.trailingSpaces(zip_1, length);
					}
					contents.append(zip_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("country_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCountry1() != null) {
					String country_1 = ob.getCountry1();
					if (country_1.length() < length) {
						country_1 = MetaData.trailingSpaces(country_1, length);
					}
					contents.append(country_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("county_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCounty1() != null) {
					String county_1 = ob.getCounty1();
					if (county_1.length() < length) {
						county_1 = MetaData.trailingSpaces(county_1, length);
					}
					contents.append(county_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("province_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getProvince1() != null) {
					String province_1 = ob.getProvince1();
					if (province_1.length() < length) {
						province_1 = MetaData
								.trailingSpaces(province_1, length);
					}
					contents.append(province_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("add_ind_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getAddInd2() != null) {
					String add_ind_2 = ob.getAddInd2();
					if (add_ind_2.length() < length) {
						add_ind_2 = MetaData.trailingSpaces(add_ind_2, length);
					}
					contents.append(add_ind_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("type_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getType2() != null) {
					String type_2 = ob.getType2();
					if (type_2.length() < length) {
						type_2 = MetaData.trailingSpaces(type_2, length);
					}
					contents.append(type_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l1_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL12() != null) {
					String l1_2 = ob.getL12();
					if (l1_2.length() < length) {
						l1_2 = MetaData.trailingSpaces(l1_2, length);
					}
					contents.append(l1_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l2_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL22() != null) {
					String l2_2 = ob.getL22();
					if (l2_2.length() < length) {
						l2_2 = MetaData.trailingSpaces(l2_2, length);
					}
					contents.append(l2_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l3_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL32() != null) {
					String l3_2 = ob.getL32();
					if (l3_2.length() < length) {
						l3_2 = MetaData.trailingSpaces(l3_2, length);
					}
					contents.append(l3_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("city_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCity2() != null) {
					String city_2 = ob.getCity2();
					if (city_2.length() < length) {
						city_2 = MetaData.trailingSpaces(city_2, length);
					}
					contents.append(city_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("state_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getState2() != null) {
					String state_2 = ob.getState2();
					if (state_2.length() < length) {
						state_2 = MetaData.trailingSpaces(state_2, length);
					}
					contents.append(state_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("zip_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getZip2() != null) {
					String zip_2 = ob.getZip2();
					if (zip_2.length() < length) {
						zip_2 = MetaData.trailingSpaces(zip_2, length);
					}
					contents.append(zip_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("country_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCountry2() != null) {
					String country_2 = ob.getCountry2();
					if (country_2.length() < length) {
						country_2 = MetaData.trailingSpaces(country_2, length);
					}
					contents.append(country_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("county_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCounty2() != null) {
					String county_2 = ob.getCounty2();
					if (county_2.length() < length) {
						county_2 = MetaData.trailingSpaces(county_2, length);
					}
					contents.append(county_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("province_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getProvince2() != null) {
					String province_2 = ob.getProvince2();
					if (province_2.length() < length) {
						province_2 = MetaData
								.trailingSpaces(province_2, length);
					}
					contents.append(province_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("add_ind_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getAddInd3() != null) {
					String add_ind_3 = ob.getAddInd3();
					if (add_ind_3.length() < length) {
						add_ind_3 = MetaData.trailingSpaces(add_ind_3, length);
					}
					contents.append(add_ind_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("type_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getType3() != null) {
					String type_3 = ob.getType3();
					if (type_3.length() < length) {
						type_3 = MetaData.trailingSpaces(type_3, length);
					}
					contents.append(type_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l1_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL13() != null) {
					String l1_3 = ob.getL13();
					if (l1_3.length() < length) {
						l1_3 = MetaData.trailingSpaces(l1_3, length);
					}
					contents.append(l1_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l2_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL23() != null) {
					String l2_3 = ob.getL23();
					if (l2_3.length() < length) {
						l2_3 = MetaData.trailingSpaces(l2_3, length);
					}
					contents.append(l2_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l3_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL33() != null) {
					String l3_3 = ob.getL33();
					if (l3_3.length() < length) {
						l3_3 = MetaData.trailingSpaces(l3_3, length);
					}
					contents.append(l3_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("city_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCity3() != null) {
					String city_3 = ob.getCity3();
					if (city_3.length() < length) {
						city_3 = MetaData.trailingSpaces(city_3, length);
					}
					contents.append(city_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("state_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getState3() != null) {
					String state_3 = ob.getState3();
					if (state_3.length() < length) {
						state_3 = MetaData.trailingSpaces(state_3, length);
					}
					contents.append(state_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("zip_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getZip3() != null) {
					String zip_3 = ob.getZip3();
					if (zip_3.length() < length) {
						zip_3 = MetaData.trailingSpaces(zip_3, length);
					}
					contents.append(zip_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("country_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCountry3() != null) {
					String country_3 = ob.getCountry3();
					if (country_3.length() < length) {
						country_3 = MetaData.trailingSpaces(country_3, length);
					}
					contents.append(country_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("county_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCounty3() != null) {
					String county_3 = ob.getCounty3();
					if (county_3.length() < length) {
						county_3 = MetaData.trailingSpaces(county_3, length);
					}
					contents.append(county_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("province_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getProvince3() != null) {
					String province_3 = ob.getProvince3();
					if (province_3.length() < length) {
						province_3 = MetaData
								.trailingSpaces(province_3, length);
					}
					contents.append(province_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("add_ind_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getAddInd4() != null) {
					String add_ind_4 = ob.getAddInd4();
					if (add_ind_4.length() < length) {
						add_ind_4 = MetaData.trailingSpaces(add_ind_4, length);
					}
					contents.append(add_ind_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("type_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getType4() != null) {
					String type_4 = ob.getType4();
					if (type_4.length() < length) {
						type_4 = MetaData.trailingSpaces(type_4, length);
					}
					contents.append(type_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l1_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL14() != null) {
					String l1_4 = ob.getL14();
					if (l1_4.length() < length) {
						l1_4 = MetaData.trailingSpaces(l1_4, length);
					}
					contents.append(l1_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l2_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL24() != null) {
					String l2_4 = ob.getL24();
					if (l2_4.length() < length) {
						l2_4 = MetaData.trailingSpaces(l2_4, length);
					}
					contents.append(l2_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("l3_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getL34() != null) {
					String l3_4 = ob.getL34();
					if (l3_4.length() < length) {
						l3_4 = MetaData.trailingSpaces(l3_4, length);
					}
					contents.append(l3_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("city_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCity4() != null) {
					String city_4 = ob.getCity4();
					if (city_4.length() < length) {
						city_4 = MetaData.trailingSpaces(city_4, length);
					}
					contents.append(city_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("state_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getState4() != null) {
					String state_4 = ob.getState4();
					if (state_4.length() < length) {
						state_4 = MetaData.trailingSpaces(state_4, length);
					}
					contents.append(state_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("zip_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getZip4() != null) {
					String zip_4 = ob.getZip4();
					if (zip_4.length() < length) {
						zip_4 = MetaData.trailingSpaces(zip_4, length);
					}
					contents.append(zip_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("country_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCountry4() != null) {
					String country_4 = ob.getCountry4();
					if (country_4.length() < length) {
						country_4 = MetaData.trailingSpaces(country_4, length);
					}
					contents.append(country_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("county_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCounty4() != null) {
					String county_4 = ob.getCounty4();
					if (county_4.length() < length) {
						county_4 = MetaData.trailingSpaces(county_4, length);
					}
					contents.append(county_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("province_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getProvince4() != null) {
					String province_4 = ob.getProvince4();
					if (province_4.length() < length) {
						province_4 = MetaData
								.trailingSpaces(province_4, length);
					}
					contents.append(province_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("home_phone_ind");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getHomePhoneInd() != null) {
					String home_phone_ind = ob.getHomePhoneInd();
					if (home_phone_ind.length() < length) {
						home_phone_ind = MetaData.appendSpaces(home_phone_ind,
								length);
					}
					contents.append(home_phone_ind);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("home_phone_country");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getHomePhoneCountry() != null) {
					String home_phone_country = ob.getHomePhoneCountry();
					if (home_phone_country.length() < length) {
						home_phone_country = MetaData.appendSpaces(
								home_phone_country, length);
					}
					contents.append(home_phone_country);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("home_phone");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getHomePhone() != null) {
					String home_phone = ob.getHomePhone();
					if (home_phone.length() < length) {
						home_phone = MetaData.appendSpaces(home_phone, length);
					}
					contents.append(home_phone);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("work_phone_ind");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getWorkPhoneInd() != null) {
					String work_phone_ind = ob.getWorkPhoneInd();
					if (work_phone_ind.length() < length) {
						work_phone_ind = MetaData.appendSpaces(work_phone_ind,
								length);
					}
					contents.append(work_phone_ind);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("work_phone_country");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getWorkPhoneCountry() != null) {
					String work_phone_country = ob.getWorkPhoneCountry();
					if (work_phone_country.length() < length) {
						work_phone_country = MetaData.appendSpaces(
								work_phone_country, length);
					}
					contents.append(work_phone_country);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("work_phone");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getWorkPhoneCountry() != null) {
					String work_phone = ob.getWorkPhoneCountry();
					if (work_phone.length() < length) {
						work_phone = MetaData.appendSpaces(work_phone, length);
					}
					contents.append(work_phone);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("work_phone_ext");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getWorkPhoneExt() != null) {
					String work_phone_ext = ob.getWorkPhoneExt();
					if (work_phone_ext.length() < length) {
						work_phone_ext = MetaData.appendSpaces(work_phone_ext,
								length);
					}
					contents.append(work_phone_ext);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("cell_phone_ind");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCellPhoneInd() != null) {
					String cell_phone_ind = ob.getCellPhoneInd();
					if (cell_phone_ind.length() < length) {
						cell_phone_ind = MetaData.appendSpaces(cell_phone_ind,
								length);
					}
					contents.append(cell_phone_ind);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("cell_phone_country");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCellPhoneCountry() != null) {
					String cell_phone_country = ob.getCellPhoneCountry();
					if (cell_phone_country.length() < length) {
						cell_phone_country = MetaData.appendSpaces(
								cell_phone_country, length);
					}
					contents.append(cell_phone_country);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("cell_phone");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getCellPhone() != null) {
					String cell_phone = ob.getCellPhone();
					if (cell_phone.length() < length) {
						cell_phone = MetaData.appendSpaces(cell_phone, length);
					}
					contents.append(cell_phone);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("pager_ind");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPagerInd() != null) {
					String pager_ind = ob.getPagerInd();
					if (pager_ind.length() < length) {
						pager_ind = MetaData.appendSpaces(pager_ind, length);
					}
					contents.append(pager_ind);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("pager_country");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPagerCountry() != null) {
					String pager_country = ob.getPagerCountry();
					if (pager_country.length() < length) {
						pager_country = MetaData.appendSpaces(pager_country,
								length);
					}
					contents.append(pager_country);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("pager");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPager() != null) {
					String pager = ob.getPager();
					if (pager.length() < length) {
						pager = MetaData.appendSpaces(pager, length);
					}
					contents.append(pager);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("pager_pin");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPagerPin() != null) {
					String pager_pin = ob.getPagerPin();
					if (pager_pin.length() < length) {
						pager_pin = MetaData.appendSpaces(pager_pin, length);
					}
					contents.append(pager_pin);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("fax_ind");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getFaxInd() != null) {
					String fax_ind = ob.getFaxInd();
					if (fax_ind.length() < length) {
						fax_ind = MetaData.appendSpaces(fax_ind, length);
					}
					contents.append(fax_ind);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("fax_country");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getFaxCountry() != null) {
					String fax_country = ob.getFaxCountry();
					if (fax_country.length() < length) {
						fax_country = MetaData
								.appendSpaces(fax_country, length);
					}
					contents.append(fax_country);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("fax");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getFax() != null) {
					String fax = ob.getFax();
					if (fax.length() < length) {
						fax = MetaData.appendSpaces(fax, length);
					}
					contents.append(fax);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("fax_ext");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getFaxExt() != null) {
					String fax_ext = ob.getFaxExt();
					if (fax_ext.length() < length) {
						fax_ext = MetaData.appendSpaces(fax_ext, length);
					}
					contents.append(fax_ext);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("other_ind");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getOtherInd() != null) {
					String other_ind = ob.getOtherInd();
					if (other_ind.length() < length) {
						other_ind = MetaData.appendSpaces(other_ind, length);
					}
					contents.append(other_ind);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("other_phone_country");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getOtherPhoneCountry() != null) {
					String other_phone_country = ob.getOtherPhoneCountry();
					if (other_phone_country.length() < length) {
						other_phone_country = MetaData.appendSpaces(
								other_phone_country, length);
					}
					contents.append(other_phone_country);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("other_phone");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getOtherPhone() != null) {
					String other_phone = ob.getOtherPhone();
					if (other_phone.length() < length) {
						other_phone = MetaData
								.appendSpaces(other_phone, length);
					}
					contents.append(other_phone);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("other_phone_ext");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getOtherPhoneExt() != null) {
					String other_phone_ext = ob.getOtherPhoneExt();
					if (other_phone_ext.length() < length) {
						other_phone_ext = MetaData.appendSpaces(
								other_phone_ext, length);
					}
					contents.append(other_phone_ext);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("email_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmail1() != null) {
					String email_1 = ob.getEmail1();
					if (email_1.length() < length) {
						email_1 = MetaData.appendSpaces(email_1, length);
					}
					contents.append(email_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("email_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmail2() != null) {
					String email_2 = ob.getEmail2();
					if (email_2.length() < length) {
						email_2 = MetaData.appendSpaces(email_2, length);
					}
					contents.append(email_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("email_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmail3() != null) {
					String email_3 = ob.getEmail3();
					if (email_3.length() < length) {
						email_3 = MetaData.appendSpaces(email_3, length);
					}
					contents.append(email_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("email_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmail4() != null) {
					String email_4 = ob.getEmail4();
					if (email_4.length() < length) {
						email_4 = MetaData.appendSpaces(email_4, length);
					}
					contents.append(email_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("email_5");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmail5() != null) {
					String email_5 = ob.getEmail5();
					if (email_5.length() < length) {
						email_5 = MetaData.appendSpaces(email_5, length);
					}
					contents.append(email_5);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("email_6");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmail6() != null) {
					String email_6 = ob.getEmail6();
					if (email_6.length() < length) {
						email_6 = MetaData.appendSpaces(email_6, length);
					}
					contents.append(email_6);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("marital_status");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getMaritalStatus() != null) {
					String marital_status = ob.getMaritalStatus();
					if (marital_status.length() < length) {
						marital_status = MetaData.appendSpaces(marital_status,
								length);
					}
					contents.append(marital_status);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("gender");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getGender() != null) {
					String gender = ob.getGender();
					if (gender.length() < length) {
						gender = MetaData.appendSpaces(gender, length);
					}
					contents.append(gender);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("birth_date");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getBirthDate() != null) {
					String birth_date = ob.getBirthDate();
					if (birth_date.length() < length) {
						birth_date = MetaData.appendSpaces(birth_date, length);
					}
					contents.append(birth_date);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_def_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerDef1() != null) {
					String employer_def_1 = ob.getEmployerDef1();
					if (employer_def_1.length() < length) {
						employer_def_1 = MetaData.appendSpaces(employer_def_1,
								length);
					}
					contents.append(employer_def_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_def_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerDef2() != null) {
					String employer_def_2 = ob.getEmployerDef2();
					if (employer_def_2.length() < length) {
						employer_def_2 = MetaData.appendSpaces(employer_def_2,
								length);
					}
					contents.append(employer_def_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_def_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerDef3() != null) {
					String employer_def_3 = ob.getEmployerDef3();
					if (employer_def_3.length() < length) {
						employer_def_3 = MetaData.appendSpaces(employer_def_3,
								length);
					}
					contents.append(employer_def_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_def_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerDef4() != null) {
					String employer_def_4 = ob.getEmployerDef4();
					if (employer_def_4.length() < length) {
						employer_def_4 = MetaData.appendSpaces(employer_def_4,
								length);
					}
					contents.append(employer_def_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_log_def_1");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerLogDef1() != null) {
					String employer_log_def_1 = ob.getEmployerLogDef1();
					if (employer_log_def_1.length() < length) {
						employer_log_def_1 = MetaData.appendSpaces(
								employer_log_def_1, length);
					}
					contents.append(employer_log_def_1);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_log_def_2");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerLogDef2() != null) {
					String employer_log_def_2 = ob.getEmployerLogDef2();
					if (employer_log_def_2.length() < length) {
						employer_log_def_2 = MetaData.appendSpaces(
								employer_log_def_2, length);
					}
					contents.append(employer_log_def_2);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_log_def_3");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerLogDef3() != null) {
					String employer_log_def_3 = ob.getEmployerLogDef3();
					if (employer_log_def_3.length() < length) {
						employer_log_def_3 = MetaData.appendSpaces(
								employer_log_def_3, length);
					}
					contents.append(employer_log_def_3);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("employer_log_def_4");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEmployerLogDef4() != null) {
					String employer_log_def_4 = ob.getEmployerLogDef4();
					if (employer_log_def_4.length() < length) {
						employer_log_def_4 = MetaData.appendSpaces(
								employer_log_def_4, length);
					}
					contents.append(employer_log_def_4);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ignorebp");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getIgnorebp() != null) {
					String ignorebp = ob.getIgnorebp();
					if (ignorebp.length() < length) {
						ignorebp = MetaData.appendSpaces(ignorebp, length);
					}
					contents.append(ignorebp);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("consent_flag");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getConsentFlag() != null) {
					String consent_flag = ob.getConsentFlag();
					if (consent_flag.length() < length) {
						consent_flag = MetaData.appendSpaces(consent_flag,
								length);
					}
					contents.append(consent_flag);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("consent_date");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getConsentDate() != null) {
					String consent_date = ob.getConsentDate();
					if (consent_date.length() < length) {
						consent_date = MetaData.appendSpaces(consent_date,
								length);
					}
					contents.append(consent_date);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("primary_email");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPrimaryEmail() != null) {
					String primary_email = ob.getPrimaryEmail();
					if (primary_email.length() < length) {
						primary_email = MetaData.appendSpaces(primary_email,
								length);
					}
					contents.append(primary_email);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("secondary_email");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getSecondaryEmail() != null) {
					String secondary_email = ob.getSecondaryEmail();
					if (secondary_email.length() < length) {
						secondary_email = MetaData.appendSpaces(
								secondary_email, length);
					}
					contents.append(secondary_email);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("address");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getAddress() != null) {
					String address = ob.getAddress();
					if (address.length() < length) {
						address = MetaData.appendSpaces(address, length);
					}
					contents.append(address);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("daytime_phone");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getDaytimePhone() != null) {
					String daytime_phone = ob.getDaytimePhone();
					if (daytime_phone.length() < length) {
						daytime_phone = MetaData.appendSpaces(daytime_phone,
								length);
					}
					contents.append(daytime_phone);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("evening_phone");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getEveningPhone() != null) {
					String evening_phone = ob.getEveningPhone();
					if (evening_phone.length() < length) {
						evening_phone = MetaData.appendSpaces(evening_phone,
								length);
					}
					contents.append(evening_phone);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				// add 73 spaces of filler here
				contents.append(MetaData.appendSpaces("", 73));
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				
				length = sizeOfColumns.get("tci_id");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getTciId() != null) {
					String tci_id = ob.getTciId();
					if (tci_id.length() < length) {
						tci_id = MetaData.appendSpaces(tci_id, length);
					}
					contents.append(tci_id);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("wotc_add");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getWotcAdd() != null) {
					String wotc_add = ob.getWotcAdd();
					if (wotc_add.length() < length) {
						wotc_add = MetaData.appendSpaces(wotc_add, length);
					}
					contents.append(wotc_add);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("tics_add");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getTicsAdd() != null) {
					String tics_add = ob.getTicsAdd();
					if (tics_add.length() < length) {
						tics_add = MetaData.appendSpaces(tics_add, length);
					}
					contents.append(tics_add);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("tax_group_name");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getTaxGroupName() != null) {
					String tax_group_name = ob.getTaxGroupName();
					if (tax_group_name.length() < length) {
						tax_group_name = MetaData.appendSpaces(tax_group_name,
								length);
					}
					contents.append(tax_group_name);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("pay_process_begin_dt");
				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				if (ob.getPayProcessBeginDt() != null) {
					String pay_process_begin_dt = ob.getPayProcessBeginDt();
					if (pay_process_begin_dt.length() < length) {
						pay_process_begin_dt = MetaData.appendSpaces(
								pay_process_begin_dt, length);
					}
					contents.append(pay_process_begin_dt);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 1 space of filler here
				contents.append(MetaData.appendSpaces("", 1));

				// add 143 spaces of filler here
				contents.append(MetaData.appendSpaces("", 143));

				System.err.println("Content Length is : " + contents.length());
				System.err.println("Length is : " + length);
				totalLength = totalLength + length;
				System.err.println("T Length is : " + totalLength);
				
				contents.append(System.getProperty("line.separator"));
				objWriteToFile.writeToFile(file, contents.toString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void writeRec210ToFile(Connection con, StringBuilder contents,
			File file, WriteToFile objWriteToFile, BigInteger pId) {

		HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
				"tx_210emplpayinfo");

		List<Rec210emplpayinfo> objRec210emplpayinfo = getRec210Facade()
				.findFinalizeRecords("Rec210emplpayinfo", 1, pId);

		System.out.println("Size of the list is : "
				+ objRec210emplpayinfo.size());
		Integer length = 0;
		Integer totalLength = 0;
		for (Rec210emplpayinfo ob : objRec210emplpayinfo) {
			contents = new StringBuilder();

			length = sizeOfColumns.get("rectype");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getRectype() != null) {
				String rectype = ob.getRectype();
				if (rectype.length() < length) {
					rectype = MetaData.appendSpaces(rectype, length);
				}
				contents.append(rectype);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("cocode");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCocode() != null) {
				String cocode = ob.getCocode();
				if (cocode.length() < length) {
					cocode = MetaData.trailingSpaces(cocode, length);
				}
				contents.append(cocode);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ssn");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getSsn() != null) {
				String ssn = ob.getSsn();
				if (ssn.length() < length) {
					ssn = MetaData.trailingSpaces(ssn, length);
				}
				contents.append(ssn);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("empl_id");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getEmplId() != null) {
				String empl_id = ob.getEmplId();
				if (empl_id.length() < length) {
					empl_id = MetaData.trailingSpaces(empl_id, length);
				}
				contents.append(empl_id);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("fein");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getFein() != null) {
				String fein = ob.getFein();
				if (fein.length() < length) {
					fein = MetaData.appendSpaces(fein, length);
				}
				contents.append(fein);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("verdiv");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getVerdiv() != null) {
				String verdiv = ob.getVerdiv();
				if (verdiv.length() < length) {
					verdiv = MetaData.appendSpaces(verdiv, length);
				}
				contents.append(verdiv);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("verpay");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getVerpay() != null) {
				String verpay = ob.getVerpay();
				if (verpay.length() < length) {
					verpay = MetaData.appendSpaces(verpay, length);
				}
				contents.append(verpay);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("pasofdate");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getPasofdate() != null) {
				String pasofdate = ob.getPasofdate();
				if (pasofdate.length() < length) {
					pasofdate = MetaData.appendSpaces(pasofdate, length);
				}
				contents.append(pasofdate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("avghours");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getAvghours() != null) {
				String avghours = ob.getAvghours();
				if (avghours.length() < length) {
					avghours = MetaData.appendSpaces(avghours, length);
				}
				contents.append(avghours);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("receiving");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getReceiving() != null) {
				String receiving = ob.getReceiving();
				if (receiving.length() < length) {
					receiving = MetaData.appendSpaces(receiving, length);
				}
				contents.append(receiving);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("carrier");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCarrier() != null) {
				String carrier = ob.getCarrier();
				if (carrier.length() < length) {
					carrier = MetaData.appendSpaces(carrier, length);
				}
				contents.append(carrier);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("injdate");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getInjdate() != null) {
				String injdate = ob.getInjdate();
				if (injdate.length() < length) {
					injdate = MetaData.appendSpaces(injdate, length);
				}
				contents.append(injdate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("awarddate");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getAwarddate() != null) {
				String awarddate = ob.getAwarddate();
				if (awarddate.length() < length) {
					awarddate = MetaData.appendSpaces(awarddate, length);
				}
				contents.append(awarddate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("claimpend");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getClaimpend() != null) {
				String claimpend = ob.getClaimpend();
				if (claimpend.length() < length) {
					claimpend = MetaData.appendSpaces(claimpend, length);
				}
				contents.append(claimpend);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("claimnum");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getClaimnum() != null) {
				String claimnum = ob.getClaimnum();
				if (claimnum.length() < length) {
					claimnum = MetaData.appendSpaces(claimnum, length);
				}
				contents.append(claimnum);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("l1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getL1() != null) {
				String l1 = ob.getL1();
				if (l1.length() < length) {
					l1 = MetaData.appendSpaces(l1, length);
				}
				contents.append(l1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("l2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getL2() != null) {
				String l2 = ob.getL2();
				if (l2.length() < length) {
					l2 = MetaData.appendSpaces(l2, length);
				}
				contents.append(l2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("city");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCity() != null) {
				String city = ob.getCity();
				if (city.length() < length) {
					city = MetaData.appendSpaces(city, length);
				}
				contents.append(city);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("state");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getState() != null) {
				String state = ob.getState();
				if (state.length() < length) {
					state = MetaData.appendSpaces(state, length);
				}
				contents.append(state);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("zip");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getZip() != null) {
				String zip = ob.getZip();
				if (zip.length() < length) {
					zip = MetaData.appendSpaces(zip, length);
				}
				contents.append(zip);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("country");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCountry() != null) {
				String country = ob.getCountry();
				if (country.length() < length) {
					country = MetaData.appendSpaces(country, length);
				}
				contents.append(country);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("deptcd");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getDeptcd() != null) {
				String deptcd = ob.getDeptcd();
				if (deptcd.length() < length) {
					deptcd = MetaData.appendSpaces(deptcd, length);
				}
				contents.append(deptcd);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("compclasscd");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCompclasscd() != null) {
				String compclasscd = ob.getCompclasscd();
				if (compclasscd.length() < length) {
					compclasscd = MetaData.appendSpaces(compclasscd, length);
				}
				contents.append(compclasscd);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("unionmem");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getUnionmem() != null) {
				String unionmem = ob.getUnionmem();
				if (unionmem.length() < length) {
					unionmem = MetaData.appendSpaces(unionmem, length);
				}
				contents.append(unionmem);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("unaffil");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getUnaffil() != null) {
				String unaffil = ob.getUnaffil();
				if (unaffil.length() < length) {
					unaffil = MetaData.appendSpaces(unaffil, length);
				}
				contents.append(unaffil);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("datenextinc");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getDatenextinc() != null) {
				String datenextinc = ob.getDatenextinc();
				if (datenextinc.length() < length) {
					datenextinc = MetaData.appendSpaces(datenextinc, length);
				}
				contents.append(datenextinc);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("amtnextinc");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getAmtnextinc() != null) {
				String amtnextinc = ob.getAmtnextinc();
				if (amtnextinc.length() < length) {
					amtnextinc = MetaData.appendSpaces(amtnextinc, length);
				}
				contents.append(amtnextinc);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("datelastinc");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getDatelastinc() != null) {
				String datelastinc = ob.getDatelastinc();
				if (datelastinc.length() < length) {
					datelastinc = MetaData.appendSpaces(datelastinc, length);
				}
				contents.append(datelastinc);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("amtlastinc");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getAmtlastinc() != null) {
				String amtlastinc = ob.getAmtlastinc();
				if (amtlastinc.length() < length) {
					amtlastinc = MetaData.appendSpaces(amtlastinc, length);
				}
				contents.append(amtlastinc);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("contemp");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getContemp() != null) {
				String contemp = ob.getContemp();
				if (contemp.length() < length) {
					contemp = MetaData.appendSpaces(contemp, length);
				}
				contents.append(contemp);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("contot");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getContot() != null) {
				String contot = ob.getContot();
				if (contot.length() < length) {
					contot = MetaData.appendSpaces(contot, length);
				}
				contents.append(contot);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("contbon");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getContbon() != null) {
				String contbon = ob.getContbon();
				if (contbon.length() < length) {
					contbon = MetaData.appendSpaces(contbon, length);
				}
				contents.append(contbon);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("daysmissed");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getDaysmissed() != null) {
				String daysmissed = ob.getDaysmissed();
				if (daysmissed.length() < length) {
					daysmissed = MetaData.appendSpaces(daysmissed, length);
				}
				contents.append(daysmissed);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("leavestart");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getLeavestart() != null) {
				String leavestart = ob.getLeavestart();
				if (leavestart.length() < length) {
					leavestart = MetaData.appendSpaces(leavestart, length);
				}
				contents.append(leavestart);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("leaveend");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getLeaveend() != null) {
				String leaveend = ob.getLeaveend();
				if (leaveend.length() < length) {
					leaveend = MetaData.appendSpaces(leaveend, length);
				}
				contents.append(leaveend);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("payrate");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getPayrate() != null) {
				String payrate = ob.getPayrate();
				if (payrate.length() < length) {
					payrate = MetaData.appendSpaces(payrate, length);
				}
				contents.append(payrate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("payratecd");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getPayratecd() != null) {
				String payratecd = ob.getPayratecd();
				if (payratecd.length() < length) {
					payratecd = MetaData.appendSpaces(payratecd, length);
				}
				contents.append(payratecd);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("cvgtot");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCvgtot() != null) {
				String cvgtot = ob.getCvgtot();
				if (cvgtot.length() < length) {
					cvgtot = MetaData.appendSpaces(cvgtot, length);
				}
				contents.append(cvgtot);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("cvgfreq");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCvgfreq() != null) {
				String cvgfreq = ob.getCvgfreq();
				if (cvgfreq.length() < length) {
					cvgfreq = MetaData.appendSpaces(cvgfreq, length);
				}
				contents.append(cvgfreq);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdate_1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getYtdate1() != null) {
				String ytdate_1 = ob.getYtdate1();
				if (ytdate_1.length() < length) {
					ytdate_1 = MetaData.appendSpaces(ytdate_1, length);
				}
				contents.append(ytdate_1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("base_1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getBase1() != null) {
				String base_1 = ob.getBase1();
				if (base_1.length() < length) {
					base_1 = MetaData.appendSpaces(base_1, length);
				}
				contents.append(base_1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ot_1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getOt1() != null) {
				String ot_1 = ob.getOt1();
				if (ot_1.length() < length) {
					ot_1 = MetaData.appendSpaces(ot_1, length);
				}
				contents.append(ot_1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("bon_1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getBon1() != null) {
				String bon_1 = ob.getBon1();
				if (bon_1.length() < length) {
					bon_1 = MetaData.appendSpaces(bon_1, length);
				}
				contents.append(bon_1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("com_1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCom1() != null) {
				String com_1 = ob.getCom1();
				if (com_1.length() < length) {
					com_1 = MetaData.appendSpaces(com_1, length);
				}
				contents.append(com_1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("other_1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getOther1() != null) {
				String other_1 = ob.getOther1();
				if (other_1.length() < length) {
					other_1 = MetaData.appendSpaces(other_1, length);
				}
				contents.append(other_1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("total_1");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getTotal1() != null) {
				String total_1 = ob.getTotal1();
				if (total_1.length() < length) {
					total_1 = MetaData.appendSpaces(total_1, length);
				}
				contents.append(total_1);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdate_2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getYtdate2() != null) {
				String ytdate_2 = ob.getYtdate2();
				if (ytdate_2.length() < length) {
					ytdate_2 = MetaData.appendSpaces(ytdate_2, length);
				}
				contents.append(ytdate_2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("base_2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getBase2() != null) {
				String base_2 = ob.getBase2();
				if (base_2.length() < length) {
					base_2 = MetaData.appendSpaces(base_2, length);
				}
				contents.append(base_2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ot_2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getOt2() != null) {
				String ot_2 = ob.getOt2();
				if (ot_2.length() < length) {
					ot_2 = MetaData.appendSpaces(ot_2, length);
				}
				contents.append(ot_2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("bon_2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getBon2() != null) {
				String bon_2 = ob.getBon2();
				if (bon_2.length() < length) {
					bon_2 = MetaData.appendSpaces(bon_2, length);
				}
				contents.append(bon_2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("com_2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCom2() != null) {
				String com_2 = ob.getCom2();
				if (com_2.length() < length) {
					com_2 = MetaData.appendSpaces(com_2, length);
				}
				contents.append(com_2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("other_2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getOther2() != null) {
				String other_2 = ob.getOther2();
				if (other_2.length() < length) {
					other_2 = MetaData.appendSpaces(other_2, length);
				}
				contents.append(other_2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("total_2");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getTotal2() != null) {
				String total_2 = ob.getTotal2();
				if (total_2.length() < length) {
					total_2 = MetaData.appendSpaces(total_2, length);
				}
				contents.append(total_2);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdate_3");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getYtdate3() != null) {
				String ytdate_3 = ob.getYtdate3();
				if (ytdate_3.length() < length) {
					ytdate_3 = MetaData.appendSpaces(ytdate_3, length);
				}
				contents.append(ytdate_3);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("base_3");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getBase3() != null) {
				String base_3 = ob.getBase3();
				if (base_3.length() < length) {
					base_3 = MetaData.appendSpaces(base_3, length);
				}
				contents.append(base_3);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ot_3");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getOt3() != null) {
				String ot_3 = ob.getOt3();
				if (ot_3.length() < length) {
					ot_3 = MetaData.appendSpaces(ot_3, length);
				}
				contents.append(ot_3);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("bon_3");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getBon3() != null) {
				String bon_3 = ob.getBon3();
				if (bon_3.length() < length) {
					bon_3 = MetaData.appendSpaces(bon_3, length);
				}
				contents.append(bon_3);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("com_3");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getCom3() != null) {
				String com_3 = ob.getCom3();
				if (com_3.length() < length) {
					com_3 = MetaData.appendSpaces(com_3, length);
				}
				contents.append(com_3);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("other_3");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getOther3() != null) {
				String other_3 = ob.getOther3();
				if (other_3.length() < length) {
					other_3 = MetaData.appendSpaces(other_3, length);
				}
				contents.append(other_3);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("total_3");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getTotal3() != null) {
				String total_3 = ob.getTotal3();
				if (total_3.length() < length) {
					total_3 = MetaData.appendSpaces(total_3, length);
				}
				contents.append(total_3);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("inhousenum");
			System.err.println("Content Length is : " + contents.length());
			System.err.println("Length is : " + length);
			totalLength = totalLength + length;
			System.err.println("T Length is : " + totalLength);
			if (ob.getInhousenum() != null) {
				String inhousenum = ob.getInhousenum();
				if (inhousenum.length() < length) {
					inhousenum = MetaData.appendSpaces(inhousenum, length);
				}
				contents.append(inhousenum);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			System.err.println("Content length at end is : "+contents.length());
			contents.append(System.getProperty("line.separator"));
			objWriteToFile.writeToFile(file, contents.toString());
			System.err.println("Total Length is : " + totalLength);
		}
	}

	private void writeRec220ToFile(Connection con, StringBuilder contents,
			File file, WriteToFile objWriteToFile, BigInteger pId) {

		HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
				"tx_220emplpaydtl");

		List<Rec220emplpaydtl> objRec220emplpayinfo = getRec220Facade()
				.findFinalizeRecords("Rec220emplpaydtl", 1, pId);

		System.out.println("Size of the list is : "
				+ objRec220emplpayinfo.size());
		Integer length = 0;

		for (Rec220emplpaydtl ob : objRec220emplpayinfo) {
			contents = new StringBuilder();

			length = sizeOfColumns.get("rectype");
			if (ob.getRectype() != null) {
				String rectype = ob.getRectype();
				if (rectype.length() < length) {
					rectype = MetaData.appendSpaces(rectype, length);
				}
				contents.append(rectype);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("cocode");
			if (ob.getCocode() != null) {
				String cocode = ob.getCocode();
				if (cocode.length() < length) {
					cocode = MetaData.trailingSpaces(cocode, length);
				}
				contents.append(cocode);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ssn");
			if (ob.getSsn() != null) {
				String ssn = ob.getSsn();
				if (ssn.length() < length) {
					ssn = MetaData.trailingSpaces(ssn, length);
				}
				contents.append(ssn);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("empl_id");
			if (ob.getEmplId() != null) {
				String empl_id = ob.getEmplId();
				if (empl_id.length() < length) {
					empl_id = MetaData.trailingSpaces(empl_id, length);
				}
				contents.append(empl_id);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("verdiv");
			if (ob.getVerdiv() != null) {
				String verdiv = ob.getVerdiv();
				if (verdiv.length() < length) {
					verdiv = MetaData.appendSpaces(verdiv, length);
				}
				contents.append(verdiv);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("payfreq");
			if (ob.getPayfreq() != null) {
				String payfreq = ob.getPayfreq();
				if (payfreq.length() < length) {
					payfreq = MetaData.appendSpaces(payfreq, length);
				}
				contents.append(payfreq);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("fein");
			if (ob.getFein() != null) {
				String fein = ob.getFein();
				if (fein.length() < length) {
					fein = MetaData.appendSpaces(fein, length);
				}
				contents.append(fein);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("suiacctnum");
			if (ob.getSuiacctnum() != null) {
				String suiacctnum = ob.getSuiacctnum();
				if (suiacctnum.length() < length) {
					suiacctnum = MetaData.appendSpaces(suiacctnum, length);
				}
				contents.append(suiacctnum);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("wrkstate");
			if (ob.getWrkstate() != null) {
				String wrkstate = ob.getWrkstate();
				if (wrkstate.length() < length) {
					wrkstate = MetaData.appendSpaces(wrkstate, length);
				}
				contents.append(wrkstate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("wrkloccd");
			if (ob.getWrkloccd() != null) {
				String wrkloccd = ob.getWrkloccd();
				if (wrkloccd.length() < length) {
					wrkloccd = MetaData.appendSpaces(wrkloccd, length);
				}
				contents.append(wrkloccd);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("wrkcountry");
			if (ob.getWrkcountry() != null) {
				String wrkcountry = ob.getWrkcountry();
				if (wrkcountry.length() < length) {
					wrkcountry = MetaData.appendSpaces(wrkcountry, length);
				}
				contents.append(wrkcountry);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("cafe");
			if (ob.getCafe() != null) {
				String cafe = ob.getCafe();
				if (cafe.length() < length) {
					cafe = MetaData.appendSpaces(cafe, length);
				}
				contents.append(cafe);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("pension");
			if (ob.getPension() != null) {
				String pension = ob.getPension();
				if (pension.length() < length) {
					pension = MetaData.appendSpaces(pension, length);
				}
				contents.append(pension);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("addincom");
			if (ob.getAddincom() != null) {
				String addincom = ob.getAddincom();
				if (addincom.length() < length) {
					addincom = MetaData.appendSpaces(addincom, length);
				}
				contents.append(addincom);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("_401k");
			if (ob.get_01k() != null) {
				String _401k = ob.get_01k();
				if (_401k.length() < length) {
					_401k = MetaData.appendSpaces(_401k, length);
				}
				contents.append(_401k);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("fedtax");
			if (ob.getFedtax() != null) {
				String fedtax = ob.getFedtax();
				if (fedtax.length() < length) {
					fedtax = MetaData.appendSpaces(fedtax, length);
				}
				contents.append(fedtax);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("statetax");
			if (ob.getStatetax() != null) {
				String statetax = ob.getStatetax();
				if (statetax.length() < length) {
					statetax = MetaData.appendSpaces(statetax, length);
				}
				contents.append(statetax);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("localtax");
			if (ob.getLocaltax() != null) {
				String localtax = ob.getLocaltax();
				if (localtax.length() < length) {
					localtax = MetaData.appendSpaces(localtax, length);
				}
				contents.append(localtax);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ficatax");
			if (ob.getFicatax() != null) {
				String ficatax = ob.getFicatax();
				if (ficatax.length() < length) {
					ficatax = MetaData.appendSpaces(ficatax, length);
				}
				contents.append(ficatax);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("medcrtax");
			if (ob.getMedcrtax() != null) {
				String medcrtax = ob.getMedcrtax();
				if (medcrtax.length() < length) {
					medcrtax = MetaData.appendSpaces(medcrtax, length);
				}
				contents.append(medcrtax);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("garn");
			if (ob.getGarn() != null) {
				String garn = ob.getGarn();
				if (garn.length() < length) {
					garn = MetaData.appendSpaces(garn, length);
				}
				contents.append(garn);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("otherwith");
			if (ob.getOtherwith() != null) {
				String otherwith = ob.getOtherwith();
				if (otherwith.length() < length) {
					otherwith = MetaData.appendSpaces(otherwith, length);
				}
				contents.append(otherwith);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("enddate");
			if (ob.getEnddate() != null) {
				String enddate = ob.getEnddate();
				if (enddate.length() < length) {
					enddate = MetaData.appendSpaces(enddate, length);
				}
				contents.append(enddate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("begdate");
			if (ob.getBegdate() != null) {
				String begdate = ob.getBegdate();
				if (begdate.length() < length) {
					begdate = MetaData.appendSpaces(begdate, length);
				}
				contents.append(begdate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paydate");
			if (ob.getPaydate() != null) {
				String paydate = ob.getPaydate();
				if (paydate.length() < length) {
					paydate = MetaData.appendSpaces(paydate, length);
				}
				contents.append(paydate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("suigross");
			if (ob.getSuigross() != null) {
				String suigross = ob.getSuigross();
				if (suigross.length() < length) {
					suigross = MetaData.appendSpaces(suigross, length);
				}
				contents.append(suigross);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_A");
			if (ob.getPaytype_A() != null) {
				String paytype_A = ob.getPaytype_A();
				if (paytype_A.length() < length) {
					paytype_A = MetaData.appendSpaces(paytype_A, length);
				}
				contents.append(paytype_A);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_A");
			if (ob.getGrosspay_A() != null) {
				String grosspay_A = ob.getGrosspay_A();
				if (grosspay_A.length() < length) {
					grosspay_A = MetaData.appendSpaces(grosspay_A, length);
				}
				contents.append(grosspay_A);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_A");
			if (ob.getNetpay_A() != null) {
				String netpay_A = ob.getNetpay_A();
				if (netpay_A.length() < length) {
					netpay_A = MetaData.appendSpaces(netpay_A, length);
				}
				contents.append(netpay_A);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_A");
			if (ob.getHours_A() != null) {
				String hours_A = ob.getHours_A();
				if (hours_A.length() < length) {
					hours_A = MetaData.appendSpaces(hours_A, length);
				}
				contents.append(hours_A);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("inhousenum");
			if (ob.getInhousenum() != null) {
				String inhousenum = ob.getInhousenum();
				if (inhousenum.length() < length) {
					inhousenum = MetaData.appendSpaces(inhousenum, length);
				}
				contents.append(inhousenum);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_R");
			if (ob.getPaytype_R() != null) {
				String paytype_R = ob.getPaytype_R();
				if (paytype_R.length() < length) {
					paytype_R = MetaData.appendSpaces(paytype_R, length);
				}
				contents.append(paytype_R);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_R");
			if (ob.getGrosspay_R() != null) {
				String grosspay_R = ob.getGrosspay_R();
				if (grosspay_R.length() < length) {
					grosspay_R = MetaData.appendSpaces(grosspay_R, length);
				}
				contents.append(grosspay_R);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_R");
			if (ob.getNetpay_R() != null) {
				String netpay_R = ob.getNetpay_R();
				if (netpay_R.length() < length) {
					netpay_R = MetaData.appendSpaces(netpay_R, length);
				}
				contents.append(netpay_R);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_R");
			if (ob.getHours_R() != null) {
				String hours_R = ob.getHours_R();
				if (hours_R.length() < length) {
					hours_R = MetaData.appendSpaces(hours_R, length);
				}
				contents.append(hours_R);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_O");
			if (ob.getPaytype_O() != null) {
				String paytype_O = ob.getPaytype_O();
				if (paytype_O.length() < length) {
					paytype_O = MetaData.appendSpaces(paytype_O, length);
				}
				contents.append(paytype_O);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_O");
			if (ob.getGrosspay_O() != null) {
				String grosspay_O = ob.getGrosspay_O();
				if (grosspay_O.length() < length) {
					grosspay_O = MetaData.appendSpaces(grosspay_O, length);
				}
				contents.append(grosspay_O);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_O");
			if (ob.getNetpay_O() != null) {
				String netpay_O = ob.getNetpay_O();
				if (netpay_O.length() < length) {
					netpay_O = MetaData.appendSpaces(netpay_O, length);
				}
				contents.append(netpay_O);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_O");
			if (ob.getHours_O() != null) {
				String hours_O = ob.getHours_O();
				if (hours_O.length() < length) {
					hours_O = MetaData.appendSpaces(hours_O, length);
				}
				contents.append(hours_O);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_V");
			if (ob.getPaytype_V() != null) {
				String paytype_V = ob.getPaytype_V();
				if (paytype_V.length() < length) {
					paytype_V = MetaData.appendSpaces(paytype_V, length);
				}
				contents.append(paytype_V);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_V");
			if (ob.getGrosspay_V() != null) {
				String grosspay_V = ob.getGrosspay_V();
				if (grosspay_V.length() < length) {
					grosspay_V = MetaData.appendSpaces(grosspay_V, length);
				}
				contents.append(grosspay_V);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_V");
			if (ob.getNetpay_V() != null) {
				String netpay_V = ob.getNetpay_V();
				if (netpay_V.length() < length) {
					netpay_V = MetaData.appendSpaces(netpay_V, length);
				}
				contents.append(netpay_V);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_V");
			if (ob.getHours_V() != null) {
				String hours_V = ob.getHours_V();
				if (hours_V.length() < length) {
					hours_V = MetaData.appendSpaces(hours_V, length);
				}
				contents.append(hours_V);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_S");
			if (ob.getPaytype_S() != null) {
				String paytype_S = ob.getPaytype_S();
				if (paytype_S.length() < length) {
					paytype_S = MetaData.appendSpaces(paytype_S, length);
				}
				contents.append(paytype_S);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_S");
			if (ob.getGrosspay_S() != null) {
				String grosspay_S = ob.getGrosspay_S();
				if (grosspay_S.length() < length) {
					grosspay_S = MetaData.appendSpaces(grosspay_S, length);
				}
				contents.append(grosspay_S);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_S");
			if (ob.getNetpay_S() != null) {
				String netpay_S = ob.getNetpay_S();
				if (netpay_S.length() < length) {
					netpay_S = MetaData.appendSpaces(netpay_S, length);
				}
				contents.append(netpay_S);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_S");
			if (ob.getHours_S() != null) {
				String hours_S = ob.getHours_S();
				if (hours_S.length() < length) {
					hours_S = MetaData.appendSpaces(hours_S, length);
				}
				contents.append(hours_S);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_H");
			if (ob.getPaytype_H() != null) {
				String paytype_H = ob.getPaytype_H();
				if (paytype_H.length() < length) {
					paytype_H = MetaData.appendSpaces(paytype_H, length);
				}
				contents.append(paytype_H);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_H");
			if (ob.getGrosspay_H() != null) {
				String grosspay_H = ob.getGrosspay_H();
				if (grosspay_H.length() < length) {
					grosspay_H = MetaData.appendSpaces(grosspay_H, length);
				}
				contents.append(grosspay_H);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_H");
			if (ob.getNetpay_H() != null) {
				String netpay_H = ob.getNetpay_H();
				if (netpay_H.length() < length) {
					netpay_H = MetaData.appendSpaces(netpay_H, length);
				}
				contents.append(netpay_H);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_H");
			if (ob.getHours_H() != null) {
				String hours_H = ob.getHours_H();
				if (hours_H.length() < length) {
					hours_H = MetaData.appendSpaces(hours_H, length);
				}
				contents.append(hours_H);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_B");
			if (ob.getPaytype_B() != null) {
				String paytype_B = ob.getPaytype_B();
				if (paytype_B.length() < length) {
					paytype_B = MetaData.appendSpaces(paytype_B, length);
				}
				contents.append(paytype_B);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_B");
			if (ob.getGrosspay_B() != null) {
				String grosspay_B = ob.getGrosspay_B();
				if (grosspay_B.length() < length) {
					grosspay_B = MetaData.appendSpaces(grosspay_B, length);
				}
				contents.append(grosspay_B);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_B");
			if (ob.getNetpay_B() != null) {
				String netpay_B = ob.getNetpay_B();
				if (netpay_B.length() < length) {
					netpay_B = MetaData.appendSpaces(netpay_B, length);
				}
				contents.append(netpay_B);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_B");
			if (ob.getHours_B() != null) {
				String hours_B = ob.getHours_B();
				if (hours_B.length() < length) {
					hours_B = MetaData.appendSpaces(hours_B, length);
				}
				contents.append(hours_B);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_E");
			if (ob.getPaytype_E() != null) {
				String paytype_E = ob.getPaytype_E();
				if (paytype_E.length() < length) {
					paytype_E = MetaData.appendSpaces(paytype_E, length);
				}
				contents.append(paytype_E);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_E");
			if (ob.getGrosspay_E() != null) {
				String grosspay_E = ob.getGrosspay_E();
				if (grosspay_E.length() < length) {
					grosspay_E = MetaData.appendSpaces(grosspay_E, length);
				}
				contents.append(grosspay_E);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_E");
			if (ob.getNetpay_E() != null) {
				String netpay_E = ob.getNetpay_E();
				if (netpay_E.length() < length) {
					netpay_E = MetaData.appendSpaces(netpay_E, length);
				}
				contents.append(netpay_E);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_E");
			if (ob.getHours_E() != null) {
				String hours_E = ob.getHours_E();
				if (hours_E.length() < length) {
					hours_E = MetaData.appendSpaces(hours_E, length);
				}
				contents.append(hours_E);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_P");
			if (ob.getPaytype_P() != null) {
				String paytype_P = ob.getPaytype_P();
				if (paytype_P.length() < length) {
					paytype_P = MetaData.appendSpaces(paytype_P, length);
				}
				contents.append(paytype_P);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_P");
			if (ob.getGrosspay_P() != null) {
				String grosspay_P = ob.getGrosspay_P();
				if (grosspay_P.length() < length) {
					grosspay_P = MetaData.appendSpaces(grosspay_P, length);
				}
				contents.append(grosspay_P);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_P");
			if (ob.getNetpay_P() != null) {
				String netpay_P = ob.getNetpay_P();
				if (netpay_P.length() < length) {
					netpay_P = MetaData.appendSpaces(netpay_P, length);
				}
				contents.append(netpay_P);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_P");
			if (ob.getHours_P() != null) {
				String hours_P = ob.getHours_P();
				if (hours_P.length() < length) {
					hours_P = MetaData.appendSpaces(hours_P, length);
				}
				contents.append(hours_P);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_W");
			if (ob.getPaytype_W() != null) {
				String paytype_W = ob.getPaytype_W();
				if (paytype_W.length() < length) {
					paytype_W = MetaData.appendSpaces(paytype_W, length);
				}
				contents.append(paytype_W);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_W");
			if (ob.getGrosspay_W() != null) {
				String grosspay_W = ob.getGrosspay_W();
				if (grosspay_W.length() < length) {
					grosspay_W = MetaData.appendSpaces(grosspay_W, length);
				}
				contents.append(grosspay_W);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_W");
			if (ob.getNetpay_W() != null) {
				String netpay_W = ob.getNetpay_W();
				if (netpay_W.length() < length) {
					netpay_W = MetaData.appendSpaces(netpay_W, length);
				}
				contents.append(netpay_W);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_W");
			if (ob.getHours_W() != null) {
				String hours_W = ob.getHours_W();
				if (hours_W.length() < length) {
					hours_W = MetaData.appendSpaces(hours_W, length);
				}
				contents.append(hours_W);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_K");
			if (ob.getPaytype_K() != null) {
				String paytype_K = ob.getPaytype_K();
				if (paytype_K.length() < length) {
					paytype_K = MetaData.appendSpaces(paytype_K, length);
				}
				contents.append(paytype_K);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_K");
			if (ob.getGrosspay_K() != null) {
				String grosspay_K = ob.getGrosspay_K();
				if (grosspay_K.length() < length) {
					grosspay_K = MetaData.appendSpaces(grosspay_K, length);
				}
				contents.append(grosspay_K);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_K");
			if (ob.getNetpay_K() != null) {
				String netpay_K = ob.getNetpay_K();
				if (netpay_K.length() < length) {
					netpay_K = MetaData.appendSpaces(netpay_K, length);
				}
				contents.append(netpay_K);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_K");
			if (ob.getHours_K() != null) {
				String hours_K = ob.getHours_K();
				if (hours_K.length() < length) {
					hours_K = MetaData.appendSpaces(hours_K, length);
				}
				contents.append(hours_K);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_C");
			if (ob.getPaytype_C() != null) {
				String paytype_C = ob.getPaytype_C();
				if (paytype_C.length() < length) {
					paytype_C = MetaData.appendSpaces(paytype_C, length);
				}
				contents.append(paytype_C);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_C");
			if (ob.getGrosspay_C() != null) {
				String grosspay_C = ob.getGrosspay_C();
				if (grosspay_C.length() < length) {
					grosspay_C = MetaData.appendSpaces(grosspay_C, length);
				}
				contents.append(grosspay_C);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_C");
			if (ob.getNetpay_C() != null) {
				String netpay_C = ob.getNetpay_C();
				if (netpay_C.length() < length) {
					netpay_C = MetaData.appendSpaces(netpay_C, length);
				}
				contents.append(netpay_C);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_C");
			if (ob.getHours_C() != null) {
				String hours_C = ob.getHours_C();
				if (hours_C.length() < length) {
					hours_C = MetaData.appendSpaces(hours_C, length);
				}
				contents.append(hours_C);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_T");
			if (ob.getPaytype_T() != null) {
				String paytype_T = ob.getPaytype_T();
				if (paytype_T.length() < length) {
					paytype_T = MetaData.appendSpaces(paytype_T, length);
				}
				contents.append(paytype_T);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_T");
			if (ob.getGrosspay_T() != null) {
				String grosspay_T = ob.getGrosspay_T();
				if (grosspay_T.length() < length) {
					grosspay_T = MetaData.appendSpaces(grosspay_T, length);
				}
				contents.append(grosspay_T);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_T");
			if (ob.getNetpay_T() != null) {
				String netpay_T = ob.getNetpay_T();
				if (netpay_T.length() < length) {
					netpay_T = MetaData.appendSpaces(netpay_T, length);
				}
				contents.append(netpay_T);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_T");
			if (ob.getHours_T() != null) {
				String hours_T = ob.getHours_T();
				if (hours_T.length() < length) {
					hours_T = MetaData.appendSpaces(hours_T, length);
				}
				contents.append(hours_T);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("paytype_M");
			if (ob.getPaytype_M() != null) {
				String paytype_M = ob.getPaytype_M();
				if (paytype_M.length() < length) {
					paytype_M = MetaData.appendSpaces(paytype_M, length);
				}
				contents.append(paytype_M);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("grosspay_M");
			if (ob.getGrosspay_M() != null) {
				String grosspay_M = ob.getGrosspay_M();
				if (grosspay_M.length() < length) {
					grosspay_M = MetaData.appendSpaces(grosspay_M, length);
				}
				contents.append(grosspay_M);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("netpay_M");
			if (ob.getNetpay_M() != null) {
				String netpay_M = ob.getNetpay_M();
				if (netpay_M.length() < length) {
					netpay_M = MetaData.appendSpaces(netpay_M, length);
				}
				contents.append(netpay_M);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hours_M");
			if (ob.getHours_M() != null) {
				String hours_M = ob.getHours_M();
				if (hours_M.length() < length) {
					hours_M = MetaData.appendSpaces(hours_M, length);
				}
				contents.append(hours_M);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			// add 1 space of filler here
			contents.append(MetaData.appendSpaces("", 1));

			contents.append(System.getProperty("line.separator"));
			objWriteToFile.writeToFile(file, contents.toString());
		}
	}

	private void writeRec290ToFile(Connection con, StringBuilder contents,
			File file, WriteToFile objWriteToFile, BigInteger pId) {

		HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
				"tx_290empltaxcrdt");

		List<Rec290empltaxcrdt> objRec290empltaxcrdts = getRec290Facade()
				.findFinalizeRecords("Rec290empltaxcrdt", 1, pId);

		System.out.println("Size of the list is : "
				+ objRec290empltaxcrdts.size());
		Integer length = 0;

		for (Rec290empltaxcrdt ob : objRec290empltaxcrdts) {
			contents = new StringBuilder();

			length = sizeOfColumns.get("rectype");
			if (ob.getRectype() != null) {
				String rectype = ob.getRectype();
				if (rectype.length() < length) {
					rectype = MetaData.appendSpaces(rectype, length);
				}
				contents.append(rectype);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("cocode");
			if (ob.getCocode() != null) {
				String cocode = ob.getCocode();
				if (cocode.length() < length) {
					cocode = MetaData.trailingSpaces(cocode, length);
				}
				contents.append(cocode);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ssn");
			if (ob.getSsn() != null) {
				String ssn = ob.getSsn();
				if (ssn.length() < length) {
					ssn = MetaData.trailingSpaces(ssn, length);
				}
				contents.append(ssn);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			// add 64 spaces of filler here
			contents.append(MetaData.appendSpaces("", 64));

			length = sizeOfColumns.get("tci_id");
			if (ob.getTciId() != null) {
				String tci_id = ob.getTciId();
				if (tci_id.length() < length) {
					tci_id = MetaData.trailingSpaces(tci_id, length);
				}
				contents.append(tci_id);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			// add 100 spaces of filler here
			contents.append(MetaData.appendSpaces("", 100));

			length = sizeOfColumns.get("wotclocnumber");
			if (ob.getWotclocnumber() != null) {
				String wotclocnumber = ob.getWotclocnumber();
				if (wotclocnumber.length() < length) {
					wotclocnumber = MetaData
							.appendSpaces(wotclocnumber, length);
				}
				contents.append(wotclocnumber);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ticsworksitelocnumber");
			if (ob.getTicsworksitelocnumber() != null) {
				String ticsworksitelocnumber = ob.getTicsworksitelocnumber();
				if (ticsworksitelocnumber.length() < length) {
					ticsworksitelocnumber = MetaData.appendSpaces(
							ticsworksitelocnumber, length);
				}
				contents.append(ticsworksitelocnumber);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("firstdayworked");
			if (ob.getFirstdayworked() != null) {
				String firstdayworked = ob.getFirstdayworked();
				if (firstdayworked.length() < length) {
					firstdayworked = MetaData.appendSpaces(firstdayworked,
							length);
				}
				contents.append(firstdayworked);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("lastcheckdate");
			if (ob.getLastcheckdate() != null) {
				String lastcheckdate = ob.getLastcheckdate();
				if (lastcheckdate.length() < length) {
					lastcheckdate = MetaData
							.appendSpaces(lastcheckdate, length);
				}
				contents.append(lastcheckdate);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdhours");
			if (ob.getYtdhours() != null) {
				String ytdhours = ob.getYtdhours();
				if (ytdhours.length() < length) {
					ytdhours = MetaData.appendSpaces(ytdhours, length);
				}
				contents.append(ytdhours);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdtips");
			if (ob.getYtdtips() != null) {
				String ytdtips = ob.getYtdtips();
				if (ytdtips.length() < length) {
					ytdtips = MetaData.appendSpaces(ytdtips, length);
				}
				contents.append(ytdtips);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdeicadvance");
			if (ob.getYtdeicadvance() != null) {
				String ytdeicadvance = ob.getYtdeicadvance();
				if (ytdeicadvance.length() < length) {
					ytdeicadvance = MetaData
							.appendSpaces(ytdeicadvance, length);
				}
				contents.append(ytdeicadvance);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdwages");
			if (ob.getYtdwages() != null) {
				String ytdwages = ob.getYtdwages();
				if (ytdwages.length() < length) {
					ytdwages = MetaData.appendSpaces(ytdwages, length);
				}
				contents.append(ytdwages);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("ytdwagesfuta");
			if (ob.getYtdwagesfuta() != null) {
				String ytdwagesfuta = ob.getYtdwagesfuta();
				if (ytdwagesfuta.length() < length) {
					ytdwagesfuta = MetaData.appendSpaces(ytdwagesfuta, length);
				}
				contents.append(ytdwagesfuta);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("fein");
			if (ob.getFein() != null) {
				String fein = ob.getFein();
				if (fein.length() < length) {
					fein = MetaData.appendSpaces(fein, length);
				}
				contents.append(fein);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("payperiodenddt");
			if (ob.getPayperiodenddt() != null) {
				String payperiodenddt = ob.getPayperiodenddt();
				if (payperiodenddt.length() < length) {
					payperiodenddt = MetaData.appendSpaces(payperiodenddt,
							length);
				}
				contents.append(payperiodenddt);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			length = sizeOfColumns.get("hourlywage");
			if (ob.getHourlywage() != null) {
				String hourlywage = ob.getHourlywage();
				if (hourlywage.length() < length) {
					hourlywage = MetaData.appendSpaces(hourlywage, length);
				}
				contents.append(hourlywage);
			} else {
				contents.append(MetaData.appendSpaces("", length));
			}

			contents.append(System.getProperty("line.separator"));
			objWriteToFile.writeToFile(file, contents.toString());
		}
	}

	private void writeRec295ToFile(Connection con, StringBuilder contents,
			File file, WriteToFile objWriteToFile, BigInteger pId) {

		HashMap<String, Integer> sizeOfColumns = MetaData.getMetaData(con,
				"tx_295emplctpaychk");

		List<Rec295EmpPayCheck> objRec295EmpPayChecks = getRec295Facade()
				.findFinalizeRecords("Rec295EmpPayCheck", 1, pId);

		System.out.println("Size of the list is : "
				+ objRec295EmpPayChecks.size());
		Integer length = 0;
		try {
			for (Rec295EmpPayCheck ob : objRec295EmpPayChecks) {
				contents = new StringBuilder();

				length = sizeOfColumns.get("rectype");
				if (ob.getRectype() != null) {
					String rectype = ob.getRectype();
					if (rectype.length() < length) {
						rectype = MetaData.appendSpaces(rectype, length);
					}
					contents.append(rectype);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("cocode");
				if (ob.getCocode() != null) {
					String cocode = ob.getCocode();
					if (cocode.length() < length) {
						cocode = MetaData.trailingSpaces(cocode, length);
					}
					contents.append(cocode);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ssn");
				if (ob.getSsn() != null) {
					String ssn = ob.getSsn();
					if (ssn.length() < length) {
						ssn = MetaData.trailingSpaces(ssn, length);
					}
					contents.append(ssn);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				// add 64 spaces of filler here
				contents.append(MetaData.appendSpaces("", 64));

				length = sizeOfColumns.get("tci_id");
				if (ob.getTci_id() != null) {
					String tci_id = ob.getTci_id();
					if (tci_id.length() < length) {
						tci_id = MetaData.trailingSpaces(tci_id, length);
					}
					contents.append(tci_id);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				// add 100 spaces of filler here
				contents.append(MetaData.appendSpaces("", 100));

				length = sizeOfColumns.get("ticsworksitelocnumber");
				if (ob.getTicsworksitelocnumber() != null) {
					String ticsworksitelocnumber = ob
							.getTicsworksitelocnumber();
					if (ticsworksitelocnumber.length() < length) {
						ticsworksitelocnumber = MetaData.appendSpaces(
								ticsworksitelocnumber, length);
					}
					contents.append(ticsworksitelocnumber);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticspaychecknumber");
				if (ob.getTicspaychecknumber() != null) {
					String ticspaychecknumber = ob.getTicspaychecknumber();
					if (ticspaychecknumber.length() < length) {
						ticspaychecknumber = MetaData.appendSpaces(
								ticspaychecknumber, length);
					}
					contents.append(ticspaychecknumber);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticspaycheckdate");
				if (ob.getTicspaycheckdate() != null) {
					String ticspaycheckdate = ob.getTicspaycheckdate();
					if (ticspaycheckdate.length() < length) {
						ticspaycheckdate = MetaData.appendSpaces(
								ticspaycheckdate, length);
					}
					contents.append(ticspaycheckdate);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticscusthours");
				if (ob.getTicscusthours() != null) {
					String ticscusthours = ob.getTicscusthours();
					if (ticscusthours.length() < length) {
						ticscusthours = MetaData.appendSpaces(ticscusthours,
								length);
					}
					contents.append(ticscusthours);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				length = sizeOfColumns.get("ticscustwages");
				if (ob.getTicscustwages() != null) {
					String ticscustwages = ob.getTicscustwages();
					if (ticscustwages.length() < length) {
						ticscustwages = MetaData.appendSpaces(ticscustwages,
								length);
					}
					contents.append(ticscustwages);
				} else {
					contents.append(MetaData.appendSpaces("", length));
				}

				contents.append(System.getProperty("line.separator"));
				objWriteToFile.writeToFile(file, contents.toString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (con != null) {
				try {
					con.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		// TODO Remove this finally block from here and add it to the last
		// method call
	}

	private void writeFooterToFile(String recType, StringBuilder contents,
			File file, WriteToFile objWriteToFile) {
		// get footer data and append it at the end of the file
		// get data of header from reference table
		recType = "tx_999footer";
		Rec999footer obj;
		obj = getFooterFacade().findSingleRecord();
		// find single record from the table, if it exists then its okay,
		// otherwise create a new record and save it in data base.
		if (obj == null) {
			obj = new Rec999footer();
			listOfSupportValues = getListOfSupportValues(recType);
			obj.setRectype(listOfSupportValues.get("rectype"));
			footerFacade.createFooter(obj);
			obj = footerFacade.findSingleRecord();
		}

		// objWriteToFile.writeToFile(filePath, contents.toString());
		// write header to the top of the file
		contents = new StringBuilder();
		contents.append(obj.getRectype());
		contents.append(System.getProperty("line.separator"));

		objWriteToFile.writeToFile(file, contents.toString());
	}

	public void exportFile(ActionEvent event) {

		// Fetch this process object and update it.
		// get status and update them in process table against this process id

		System.out.println("exportFile called sys");
		// FixedFormatManager manager = new FixedFormatManagerImpl();

		Long dateTime = System.currentTimeMillis();
		WriteToFile objWriteToFile = new WriteToFile();
		@SuppressWarnings("deprecation")
		String path = URLDecoder.decode(this.getClass().getClassLoader()
				.getResource("downloads").getPath());
		path = path.substring(1);
		System.out.println(path);
		// TODO change this file path to some path at the web server.
		String filePath = path + dateTime + ".txt";
		File file = objWriteToFile.createFile(filePath);
		BigInteger pId = Util.getBigInteger(process.getId());

		// StringBuffer contents = new StringBuffer();
		StringBuilder contents = new StringBuilder();

		// String recordSeperator = "\r \n";
		String recType = "tx_000header";

		writeHeaderToFile(recType, contents, file, objWriteToFile);

		contents = new StringBuilder();
		Connection con = null;
		try {
			// TODO find current database which is in use and then create the
			// connection on its basis.
			// con =
			// DBConnectionManager.getConnection(DBConnectionManager.MYSQL);
			con = DBConnectionManager
					.getConnection(DBConnectionManager.SQLSERVER);
			writeRec140ToFile(con, contents, file, objWriteToFile, pId);
		} catch (Exception e) {
			e.printStackTrace();
		}

		contents = new StringBuilder();
		if (con == null) {
			try {
				// TODO find current database which is in use and then create
				// the
				// connection on its basis.
				// con =
				// DBConnectionManager.getConnection(DBConnectionManager.MYSQL);
				con = DBConnectionManager
						.getConnection(DBConnectionManager.SQLSERVER);
				writeRec150ToFile(con, contents, file, objWriteToFile, pId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			writeRec150ToFile(con, contents, file, objWriteToFile, pId);
		}

		contents = new StringBuilder();
		if (con == null) {
			try {
				con = DBConnectionManager
						.getConnection(DBConnectionManager.SQLSERVER);
				writeRec202ToFile(con, contents, file, objWriteToFile, pId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			writeRec202ToFile(con, contents, file, objWriteToFile, pId);
		}

		contents = new StringBuilder();
		if (con == null) {
			try {
				con = DBConnectionManager
						.getConnection(DBConnectionManager.SQLSERVER);
				writeRec210ToFile(con, contents, file, objWriteToFile, pId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			writeRec210ToFile(con, contents, file, objWriteToFile, pId);
		}

		contents = new StringBuilder();
		if (con == null) {
			try {
				con = DBConnectionManager
						.getConnection(DBConnectionManager.SQLSERVER);
				writeRec220ToFile(con, contents, file, objWriteToFile, pId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			writeRec220ToFile(con, contents, file, objWriteToFile, pId);
		}

		contents = new StringBuilder();
		if (con == null) {
			try {
				con = DBConnectionManager
						.getConnection(DBConnectionManager.SQLSERVER);
				writeRec290ToFile(con, contents, file, objWriteToFile, pId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			writeRec290ToFile(con, contents, file, objWriteToFile, pId);
		}

		contents = new StringBuilder();
		if (con == null) {
			try {
				con = DBConnectionManager
						.getConnection(DBConnectionManager.SQLSERVER);
				writeRec295ToFile(con, contents, file, objWriteToFile, pId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			writeRec295ToFile(con, contents, file, objWriteToFile, pId);
		}

		contents = new StringBuilder();
		recType = "tx_999footer";
		writeFooterToFile(recType, contents, file, objWriteToFile);
		try {
			if (con != null) {
				if (!(con.isClosed())) {
					try {
						con.close();
					} catch (SQLException e) {
						e.printStackTrace();
					}
				}
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		// displayInfoMessageToUser(objRec140erwotclocs.size()
		// + " records exported successfully!!!");
		// return "";
		generateReport(file);
	}

	// public void exportFile() {
	// System.out.println("exportFile called sys");
	// }

	public void generateReport(File file) {
		// System.out.println("GENERATE REPORT FROM = " + this.dateFrom +
		// "; TO = " + this.dateTo);

		try {

			FacesContext fc = FacesContext.getCurrentInstance();
			ExternalContext ec = fc.getExternalContext();

			// Some JSF component library or some Filter might have set some
			// headers in the buffer beforehand. We want to get rid of them,
			// else it may collide.
			ec.responseReset();

			// Check http://www.w3schools.com/media/media_mimeref.asp for all
			// types. Use if necessary ExternalContext#getMimeType() for
			// auto-detection based on filename.
			ec.setResponseContentType("application/text-plain");

			// Set it with the file size. This header is optional. It will work
			// if it's omitted, but the download progress will be unknown.
			// ec.setResponseContentLength(contentLength);

			// The Save As popup magic is done here. You can give it any file
			// name you want, this only won't work in MSIE, it will use current
			// request URL as file name instead.
			ec.setResponseHeader("Content-Disposition",
					"attachment; filename=\"" + file.getName() + "\"");

			OutputStream output = ec.getResponseOutputStream();
			// workbook.write(output);
			// File file = new File(filePath);
			String sCurrentLine;

			BufferedReader br = new BufferedReader(new FileReader(file));
			StringBuffer contents = new StringBuffer();
			while ((sCurrentLine = br.readLine()) != null) {
				// System.out.println(sCurrentLine);
				contents.append(sCurrentLine);
				contents.append(System.getProperty("line.separator"));
			}
			br.close();
			// get the content in bytes
			byte[] contentInBytes = contents.toString().getBytes();

			output.write(contentInBytes);

			output.flush();
			output.close();

			fc.responseComplete(); // Important! Otherwise JSF will attempt to
									// render the response which obviously will
									// fail since it's already written with a
									// file and closed.
			System.out.println("END");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void sendFileToFtp() {
		logger.info("sendFileToFtp called");
		System.out.println("sendFileToFtp called sys");
	}

	public void showHideButtons(SelectEvent event) {
		System.out.println("I am called");
		if (this.getSelectedProcess().getStatus().equals("Finalized")) {

			finalizedButtonVisible = "true";
			exportCurrentButtonVisible = "false";
			reloadButtonVisible = "false";
		} else {
			finalizedButtonVisible = "false";
			exportCurrentButtonVisible = "false";
			reloadButtonVisible = "false";
		}
		process = this.getSelectedProcess();
	}

	/**
	 * @return the list
	 */
	public List<Process> getList() {
		if (list == null) {
			list = new ArrayList<Process>();
		}
		list = getFacade().findAllProcesses();
		return list;
	}

	/**
	 * @param list
	 *            the list to set
	 */
	public void setList(List<Process> list) {
		this.list = list;
	}

	/**
	 * @return the facade
	 */
	public ProcessFacade getFacade() {
		if (facade == null) {
			facade = new ProcessFacade();
		}
		return facade;
	}

	/**
	 * @param facade
	 *            the facade to set
	 */
	public void setFacade(ProcessFacade facade) {
		this.facade = facade;
	}

	/**
	 * @return the selectedProcess
	 */
	public Process getSelectedProcess() {
		return selectedProcess;
	}

	/**
	 * @param selectedProcess
	 *            the selectedProcess to set
	 */
	public void setSelectedProcess(Process selectedProcess) {
		this.selectedProcess = selectedProcess;
	}

	/**
	 * @return the reloadButtonVisible
	 */
	public String getReloadButtonVisible() {
		return reloadButtonVisible;
	}

	/**
	 * @param reloadButtonVisible
	 *            the reloadButtonVisible to set
	 */
	public void setReloadButtonVisible(String reloadButtonVisible) {
		this.reloadButtonVisible = reloadButtonVisible;
	}

	/**
	 * @return the finalizedButtonVisible
	 */
	public String getFinalizedButtonVisible() {
		return finalizedButtonVisible;
	}

	/**
	 * @param finalizedButtonVisible
	 *            the finalizedButtonVisible to set
	 */
	public void setFinalizedButtonVisible(String finalizedButtonVisible) {
		this.finalizedButtonVisible = finalizedButtonVisible;
	}

	/**
	 * @return the exportCurrentButtonVisible
	 */
	public String getExportCurrentButtonVisible() {
		return exportCurrentButtonVisible;
	}

	/**
	 * @param exportCurrentButtonVisible
	 *            the exportCurrentButtonVisible to set
	 */
	public void setExportCurrentButtonVisible(String exportCurrentButtonVisible) {
		this.exportCurrentButtonVisible = exportCurrentButtonVisible;
	}

	/**
	 * @return the ftpButtonVisible
	 */
	public String getFtpButtonVisible() {
		return ftpButtonVisible;
	}

	/**
	 * @param ftpButtonVisible
	 *            the ftpButtonVisible to set
	 */
	public void setFtpButtonVisible(String ftpButtonVisible) {
		this.ftpButtonVisible = ftpButtonVisible;
	}

	/**
	 * @return the recFacade
	 */
	public Rec140ERWOTCLOCFacade getRec140Facade() {
		if (rec140Facade == null) {
			rec140Facade = new Rec140ERWOTCLOCFacade();
		}
		return rec140Facade;
	}

	/**
	 * @param recFacade
	 *            the recFacade to set
	 */
	public void setRec140Facade(Rec140ERWOTCLOCFacade recFacade) {
		this.rec140Facade = recFacade;
	}

	/**
	 * @return the objFacade
	 */
	public RecReferenceValueFacade getObjFacade() {
		if (objFacade == null) {
			objFacade = new RecReferenceValueFacade();
		}
		return objFacade;
	}

	/**
	 * @param objFacade
	 *            the objFacade to set
	 */
	public void setObjFacade(RecReferenceValueFacade objFacade) {
		this.objFacade = objFacade;
	}

	/**
	 * @param listOfSupportValues
	 *            the listOfSupportValues to set
	 */
	public void setListOfSupportValues(Map<String, String> listOfSupportValues) {
		this.listOfSupportValues = listOfSupportValues;
	}

	/**
	 * @return the headerFacade
	 */
	public Rec000headerFacade getHeaderFacade() {
		if (headerFacade == null) {
			headerFacade = new Rec000headerFacade();
		}
		return headerFacade;
	}

	/**
	 * @param headerFacade
	 *            the headerFacade to set
	 */
	public void setHeaderFacade(Rec000headerFacade headerFacade) {
		this.headerFacade = headerFacade;
	}

	/**
	 * @return the footerFacade
	 */
	public Rec999footerFacade getFooterFacade() {
		if (footerFacade == null) {
			footerFacade = new Rec999footerFacade();
		}
		return footerFacade;
	}

	/**
	 * @param footerFacade
	 *            the footerFacade to set
	 */
	public void setFooterFacade(Rec999footerFacade footerFacade) {
		this.footerFacade = footerFacade;
	}

	/**
	 * @return the rec150Facade
	 */
	public Rec150erticswksiteFacade getRec150Facade() {
		if (rec150Facade == null) {
			rec150Facade = new Rec150erticswksiteFacade();
		}
		return rec150Facade;
	}

	/**
	 * @param rec150Facade
	 *            the rec150Facade to set
	 */
	public void setRec150Facade(Rec150erticswksiteFacade rec150Facade) {
		this.rec150Facade = rec150Facade;
	}

	/**
	 * @return the reloadSpecific
	 */
	public String getReloadSpecific() {
		return reloadSpecific;
	}

	/**
	 * @param reloadSpecific
	 *            the reloadSpecific to set
	 */
	public void setReloadSpecific(String reloadSpecific) {
		this.reloadSpecific = reloadSpecific;
	}

	/**
	 * @return the selectedRecord
	 */
	public String getSelectedRecordId() {
		return selectedRecordId;
	}

	/**
	 * @param selectedRecord
	 *            the selectedRecord to set
	 */
	public void setSelectedRecordId(String selectedRecordId) {
		this.selectedRecordId = selectedRecordId;
	}

	/**
	 * @return the selectedProcessId
	 */
	public Integer getSelectedProcessId() {
		return selectedProcessId;
	}

	/**
	 * @param selectedProcessId
	 *            the selectedProcessId to set
	 */
	public void setSelectedProcessId(Integer selectedProcessId) {
		this.selectedProcessId = selectedProcessId;
	}

	/**
	 * @return the recordTypeList
	 */
	public Map<String, String> getRecordTypeList() {
		if (recordTypeList == null) {
			recordTypeList = new LinkedHashMap<String, String>(7);
			recordTypeList.put(IRecordType.REC140, IReferenceType.REC_140_REF);
			recordTypeList.put(IRecordType.REC150, IReferenceType.REC_150_REF);
			recordTypeList.put(IRecordType.REC202, IReferenceType.REC_202_REF);
			recordTypeList.put(IRecordType.REC210, IReferenceType.REC_210_REF);
			recordTypeList.put(IRecordType.REC220, IReferenceType.REC_220_REF);
			recordTypeList.put(IRecordType.REC290, IReferenceType.REC_290_REF);
			recordTypeList.put(IRecordType.REC295, IReferenceType.REC_295_REF);
		}
		return recordTypeList;
	}

	/**
	 * @param recordTypeList
	 *            the recordTypeList to set
	 */
	public void setRecordTypeList(Map<String, String> recordTypeList) {
		this.recordTypeList = recordTypeList;
	}

	/**
	 * @return the processList
	 */
	public Map<Integer, Integer> getProcessList() {
		if (processList == null) {
			processList = new LinkedHashMap<Integer, Integer>();
			List<Integer> list = getFacade().getAllProcessIds(
					IRecordType.PROCESS);
			for (int i = 0; i < list.size(); i++) {
				processList.put(list.get(i), list.get(i));
			}
		}
		return processList;
	}

	/**
	 * @param processList
	 *            the processList to set
	 */
	public void setProcessList(Map<Integer, Integer> processList) {
		this.processList = processList;
	}

	/**
	 * @return the rec202Facade
	 */
	public Rec202emplpimFacade getRec202Facade() {
		if (rec202Facade == null) {
			rec202Facade = new Rec202emplpimFacade();
		}
		return rec202Facade;
	}

	/**
	 * @param rec202Facade
	 *            the rec202Facade to set
	 */
	public void setRec202Facade(Rec202emplpimFacade rec202Facade) {
		this.rec202Facade = rec202Facade;
	}

	/**
	 * @return the rec210Facade
	 */
	public Rec210emplpayinfoFacade getRec210Facade() {
		if (rec210Facade == null) {
			rec210Facade = new Rec210emplpayinfoFacade();
		}
		return rec210Facade;
	}

	/**
	 * @param rec210Facade
	 *            the rec210Facade to set
	 */
	public void setRec210Facade(Rec210emplpayinfoFacade rec210Facade) {
		this.rec210Facade = rec210Facade;
	}

	/**
	 * @return the rec220Facade
	 */
	public Rec220emplpaydtlFacade getRec220Facade() {
		if (rec220Facade == null) {
			rec220Facade = new Rec220emplpaydtlFacade();
		}
		return rec220Facade;
	}

	/**
	 * @param rec220Facade
	 *            the rec220Facade to set
	 */
	public void setRec220Facade(Rec220emplpaydtlFacade rec220Facade) {
		this.rec220Facade = rec220Facade;
	}

	/**
	 * @return the rec290Facade
	 */
	public Rec290empltaxcrdtFacade getRec290Facade() {
		if (rec290Facade == null) {
			rec290Facade = new Rec290empltaxcrdtFacade();
		}
		return rec290Facade;
	}

	/**
	 * @param rec290Facade
	 *            the rec290Facade to set
	 */
	public void setRec290Facade(Rec290empltaxcrdtFacade rec290Facade) {
		this.rec290Facade = rec290Facade;
	}

	/**
	 * @return the rec295Facade
	 */
	public Rec295Facade getRec295Facade() {
		if (rec295Facade == null) {
			rec295Facade = new Rec295Facade();
		}
		return rec295Facade;
	}

	/**
	 * @param rec295Facade
	 *            the rec295Facade to set
	 */
	public void setRec295Facade(Rec295Facade rec295Facade) {
		this.rec295Facade = rec295Facade;
	}

}
